Skip to content

Commit f3c4d69

Browse files
committed
rmt notebooks
1 parent f255bf4 commit f3c4d69

File tree

4 files changed

+1532
-30
lines changed

4 files changed

+1532
-30
lines changed

notebooks/circular.jl

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,27 @@ end
4747
# ╔═╡ db8c16a0-79df-4cc0-9c69-a6bcfcd23a1c
4848
circular(3,2)
4949

50-
# ╔═╡ f9f00c9d-633a-4734-838f-3ffdcef6efe0
51-
@bind β Slider([.5,1,4,10,100,1000,1e10]; default=1, show_value=true)
50+
# ╔═╡ 02db4122-8e3c-477c-b1ef-d9c236787910
51+
smallabs(U) = minimum(abs.(angle.(eigvals(Matrix(U)))))
52+
53+
# ╔═╡ 14b4a088-ff74-43f3-b301-4057593c0447
54+
function circular2(n)
55+
A = randn(n,n) .+ im * randn(n,n)
56+
U = qr(A).Q .* cis.(2π*rand(n))
57+
end
58+
59+
# ╔═╡ 148317c1-e48f-4d39-833c-b51d2c43e5fd
60+
function circular1(n) #β=1
61+
A = randn(n,n) .+ im * randn(n,n)
62+
U = qr(A).Q * transpose( Matrix(qr(A).Q ))
63+
end
5264

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

68+
# ╔═╡ f9f00c9d-633a-4734-838f-3ffdcef6efe0
69+
@bind β Slider([.5,1,4,10,50,100,1000,1e10]; default=1, show_value=true)
70+
5671
# ╔═╡ 63cd9672-d3d2-4b2a-8076-f98b60dc11e6
5772
begin
5873
e = eigvals(circular(n,β))
@@ -64,36 +79,23 @@ begin
6479
plot!(cis.(θ),label=false)
6580
end
6681

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

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

76-
# ╔═╡ 148317c1-e48f-4d39-833c-b51d2c43e5fd
77-
function circular1(n) #β=1
78-
A = randn(n,n) .+ im * randn(n,n)
79-
U = qr(A).Q * transpose( Matrix(qr(A).Q ))
87+
# m = [ smallabs(circular2(n)) for i=1:t]
88+
# display((mean(m),var(m)))
89+
# stephist(m,normalize=true,label="dense")
90+
mh = [ smallabs(circular(n,β)) for i=1:t]
91+
#display((mean(mh),var(mh)))
92+
93+
stephist(mh,normalize=true,label="Hessenberg")
94+
title!("β= n=$n t=$t")
8095
end
8196

82-
# ╔═╡ 5cd13d1b-9bb4-4a19-9e6a-07e214572639
83-
# ╠═╡ disabled = true
84-
#=╠═╡
85-
let
86-
n = 5
87-
t = 50
88-
m = [ smallabs(circular2(n)) for i=1:t]
89-
display((mean(m),var(m)))
90-
stephist(m,normalize=true,label="dense")
91-
mh = [ smallabs(circular(n,2)) for i=1:t]
92-
display((mean(mh),var(mh)))
93-
title!("β=2 n=$n t=$t")
94-
stephist!(mh,normalize=true,label="Hessenberg")
95-
end
96-
╠═╡ =#
97+
# ╔═╡ a6be0162-84fd-408c-b3d6-d3cee3b58b61
98+
9799

98100
# ╔═╡ 63bf73bf-b312-49cc-a909-c043bfc80fd1
99101
circular1(5)
@@ -1369,14 +1371,15 @@ version = "1.4.1+1"
13691371
# ╠═fab8681e-0be3-4d97-a0cb-2ad57472282a
13701372
# ╠═5455f492-7c41-11ef-3315-19809ebaffc3
13711373
# ╠═db8c16a0-79df-4cc0-9c69-a6bcfcd23a1c
1372-
# ╠═f9f00c9d-633a-4734-838f-3ffdcef6efe0
1373-
# ╠═e4418523-234c-4faa-a29b-43484013b322
13741374
# ╠═63cd9672-d3d2-4b2a-8076-f98b60dc11e6
13751375
# ╠═02db4122-8e3c-477c-b1ef-d9c236787910
13761376
# ╠═14b4a088-ff74-43f3-b301-4057593c0447
13771377
# ╠═148317c1-e48f-4d39-833c-b51d2c43e5fd
13781378
# ╠═2443d72e-42f4-4f66-8170-04633f9b9031
1379+
# ╠═e4418523-234c-4faa-a29b-43484013b322
1380+
# ╠═f9f00c9d-633a-4734-838f-3ffdcef6efe0
13791381
# ╠═5cd13d1b-9bb4-4a19-9e6a-07e214572639
1382+
# ╠═a6be0162-84fd-408c-b3d6-d3cee3b58b61
13801383
# ╠═63bf73bf-b312-49cc-a909-c043bfc80fd1
13811384
# ╠═82ce98e9-37a9-4023-ac62-5c092a8fa932
13821385
# ╠═5e4d9a97-db38-445e-8982-7813b9656546

notebooks/geometric_sequence

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a,r,n refers implicitly to \rightarrow a,ar,ar^2,\ldots,ar^{n-1}$$

notebooks/geometric_sequence.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# g(a,r,n) = geometric_sequence
2+
# refers implicitly to → a,ar,ar²,…, arⁿ⁻¹
3+
4+
# state(i,t) = iteration number and current term (i.e. t = arⁱ)
5+
# start = state(0,i)
6+
# next = (i,t) → (i+1, r*t)
7+
# done when i=n
8+
9+
struct geometric_sequence
10+
a :: Float64 # start
11+
r :: Float64 # ratio
12+
n :: Int # number of terms
13+
end
14+
15+
struct geometric_sequence_state
16+
i :: Int # iteration number
17+
t :: Float64 # current term
18+
end
19+
20+
iterate(g::geometric_sequence) = geometric_sequence_state(0,g.a) # start
21+
22+
# next should return term and state
23+
function iterate(g::geometric_sequence, s::geometric_sequence_state)
24+
s.t, geometric_sequence_state(s.i+1, g.r * s.t )
25+
end

0 commit comments

Comments
 (0)