In [1]:
using Plots
In [22]:
plot(cumsum(randn(100)))
Out[22]:
In [23]:
savefig("mycs520-figure.pdf")
Out[23]:
"/Users/dgleich/Dropbox/courses/cs520-2023/web/input/julia/mycs520-figure.pdf"
In [7]:
X = randn(100,1)
Out[7]:
100×1 Matrix{Float64}:
  0.5555303079694842
 -0.9643002501710098
  0.3185010143105035
  0.5358656681010048
  0.7244377283963698
  0.5569010993317579
 -0.9611473632444195
 -1.148041116380844
  0.3843077757385845
 -0.3025517548094711
  0.8194927722534551
  0.3279550861596789
  0.9510116176144341
  ⋮
  0.28409673421421444
  0.20611881070430307
  0.2614144461558663
  1.1483960474582213
 -1.2700992620048341
 -0.14953798800856735
 -0.6055185948384988
  0.7126834557906986
  0.4641266750064072
  0.20364395101511182
  0.10196471677395817
 -0.4917173113725836
In [9]:
vec(X) == X
Out[9]:
false
In [10]:
1
Out[10]:
1
In [11]:
typeof(1)
Out[11]:
Int64
In [12]:
typeof(1.0)
Out[12]:
Float64
In [13]:
1/5
Out[13]:
0.2
In [14]:
0 ÷ 5
Out[14]:
0
In [15]:
div(0,5)
Out[15]:
0
In [16]:
α = 5.0
Out[16]:
5.0
In [17]:
β = 2.3
Out[17]:
2.3
In [18]:
α*β
Out[18]:
11.5
In [19]:
😀 = 10
Out[19]:
10
In [21]:
factorial(😀)
Out[21]:
3628800
In [24]:
X = [1.0, 2, 3]
Out[24]:
3-element Vector{Float64}:
 1.0
 2.0
 3.0
In [25]:
X[1]
Out[25]:
1.0
In [27]:
import Pkg; Pkg.add("OffsetArrays")
┌ Warning: could not download https://pkg.julialang.org/registries
│   exception = Could not resolve host: pkg.julialang.org while requesting https://pkg.julialang.org/registries
└ @ Pkg.Registry /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-4.0/build/default-macmini-aarch64-4-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:68
    Updating registry at `~/.julia/registries/General`
    Updating git-repo `https://github.com/JuliaRegistries/General.git`
┌ Error: Some registries failed to update:
│     — /Users/dgleich/.julia/registries/General — failed to fetch from repo: failed to fetch from https://github.com/JuliaRegistries/General.git, error: GitError(Code:ERROR, Class:Net, failed to resolve address for github.com: nodename nor servname provided, or not known)
└ @ Pkg.Registry /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-macmini-aarch64-4.0/build/default-macmini-aarch64-4-0/julialang/julia-release-1-dot-8/usr/share/julia/stdlib/v1.8/Pkg/src/Registry/Registry.jl:449
   Resolving package versions...
    Updating `~/.julia/environments/v1.8/Project.toml`
  [6fe1bfb0] + OffsetArrays v1.12.8
  No Changes to `~/.julia/environments/v1.8/Manifest.toml`
In [28]:
using OffsetArrays
In [30]:
x = OffsetVector(rand(10), 0:9)
Out[30]:
10-element OffsetArray(::Vector{Float64}, 0:9) with eltype Float64 with indices 0:9:
 0.7678722316084888
 0.7713737318835239
 0.6812864288721118
 0.9446438842898601
 0.13310007421807857
 0.8870429102714432
 0.9282221974850758
 0.7819518714458586
 0.7796844465528503
 0.5874710198835819
In [31]:
x[0]
Out[31]:
0.7678722316084888
In [ ]: