Skip to content

Commit

Permalink
rmt notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
alanedelman committed Oct 6, 2024
1 parent f255bf4 commit f3c4d69
Show file tree
Hide file tree
Showing 4 changed files with 1,532 additions and 30 deletions.
63 changes: 33 additions & 30 deletions notebooks/circular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,27 @@ end
# ╔═╡ db8c16a0-79df-4cc0-9c69-a6bcfcd23a1c
circular(3,2)

# ╔═╡ f9f00c9d-633a-4734-838f-3ffdcef6efe0
@bind β Slider([.5,1,4,10,100,1000,1e10]; default=1, show_value=true)
# ╔═╡ 02db4122-8e3c-477c-b1ef-d9c236787910
smallabs(U) = minimum(abs.(angle.(eigvals(Matrix(U)))))

# ╔═╡ 14b4a088-ff74-43f3-b301-4057593c0447
function circular2(n)
A = randn(n,n) .+ im * randn(n,n)
U = qr(A).Q .* cis.(2π*rand(n))
end

# ╔═╡ 148317c1-e48f-4d39-833c-b51d2c43e5fd
function circular1(n) #β=1
A = randn(n,n) .+ im * randn(n,n)
U = qr(A).Q * transpose( Matrix(qr(A).Q ))
end

# ╔═╡ e4418523-234c-4faa-a29b-43484013b322
@bind n Slider(2:17; default=3, show_value=true)

# ╔═╡ f9f00c9d-633a-4734-838f-3ffdcef6efe0
@bind β Slider([.5,1,4,10,50,100,1000,1e10]; default=1, show_value=true)

# ╔═╡ 63cd9672-d3d2-4b2a-8076-f98b60dc11e6
begin
e = eigvals(circular(n,β))
Expand All @@ -64,36 +79,23 @@ begin
plot!(cis.(θ),label=false)
end

# ╔═╡ 02db4122-8e3c-477c-b1ef-d9c236787910
smallabs(U) = minimum(abs.(angle.(eigvals(Matrix(U)))))
# ╔═╡ 5cd13d1b-9bb4-4a19-9e6a-07e214572639
begin

# ╔═╡ 14b4a088-ff74-43f3-b301-4057593c0447
function circular2(n)
A = randn(n,n) .+ im * randn(n,n)
U = qr(A).Q .* cis.(2π*rand(n))
end
t = 20

# ╔═╡ 148317c1-e48f-4d39-833c-b51d2c43e5fd
function circular1(n) #β=1
A = randn(n,n) .+ im * randn(n,n)
U = qr(A).Q * transpose( Matrix(qr(A).Q ))
# m = [ smallabs(circular2(n)) for i=1:t]
# display((mean(m),var(m)))
# stephist(m,normalize=true,label="dense")
mh = [ smallabs(circular(n,β)) for i=1:t]
#display((mean(mh),var(mh)))

stephist(mh,normalize=true,label="Hessenberg")
title!("β= n=$n t=$t")
end

# ╔═╡ 5cd13d1b-9bb4-4a19-9e6a-07e214572639
# ╠═╡ disabled = true
#=╠═╡
let
n = 5
t = 50
m = [ smallabs(circular2(n)) for i=1:t]
display((mean(m),var(m)))
stephist(m,normalize=true,label="dense")
mh = [ smallabs(circular(n,2)) for i=1:t]
display((mean(mh),var(mh)))
title!("β=2 n=$n t=$t")
stephist!(mh,normalize=true,label="Hessenberg")
end
╠═╡ =#
# ╔═╡ a6be0162-84fd-408c-b3d6-d3cee3b58b61


# ╔═╡ 63bf73bf-b312-49cc-a909-c043bfc80fd1
circular1(5)
Expand Down Expand Up @@ -1369,14 +1371,15 @@ version = "1.4.1+1"
# ╠═fab8681e-0be3-4d97-a0cb-2ad57472282a
# ╠═5455f492-7c41-11ef-3315-19809ebaffc3
# ╠═db8c16a0-79df-4cc0-9c69-a6bcfcd23a1c
# ╠═f9f00c9d-633a-4734-838f-3ffdcef6efe0
# ╠═e4418523-234c-4faa-a29b-43484013b322
# ╠═63cd9672-d3d2-4b2a-8076-f98b60dc11e6
# ╠═02db4122-8e3c-477c-b1ef-d9c236787910
# ╠═14b4a088-ff74-43f3-b301-4057593c0447
# ╠═148317c1-e48f-4d39-833c-b51d2c43e5fd
# ╠═2443d72e-42f4-4f66-8170-04633f9b9031
# ╠═e4418523-234c-4faa-a29b-43484013b322
# ╠═f9f00c9d-633a-4734-838f-3ffdcef6efe0
# ╠═5cd13d1b-9bb4-4a19-9e6a-07e214572639
# ╠═a6be0162-84fd-408c-b3d6-d3cee3b58b61
# ╠═63bf73bf-b312-49cc-a909-c043bfc80fd1
# ╠═82ce98e9-37a9-4023-ac62-5c092a8fa932
# ╠═5e4d9a97-db38-445e-8982-7813b9656546
Expand Down
1 change: 1 addition & 0 deletions notebooks/geometric_sequence
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a,r,n refers implicitly to \rightarrow a,ar,ar^2,\ldots,ar^{n-1}$$
25 changes: 25 additions & 0 deletions notebooks/geometric_sequence.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# g(a,r,n) = geometric_sequence
# refers implicitly to → a,ar,ar²,…, arⁿ⁻¹

# state(i,t) = iteration number and current term (i.e. t = arⁱ)
# start = state(0,i)
# next = (i,t) → (i+1, r*t)
# done when i=n

struct geometric_sequence
a :: Float64 # start
r :: Float64 # ratio
n :: Int # number of terms
end

struct geometric_sequence_state
i :: Int # iteration number
t :: Float64 # current term
end

iterate(g::geometric_sequence) = geometric_sequence_state(0,g.a) # start

# next should return term and state
function iterate(g::geometric_sequence, s::geometric_sequence_state)
s.t, geometric_sequence_state(s.i+1, g.r * s.t )
end
Loading

0 comments on commit f3c4d69

Please sign in to comment.