File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ # bellcurve2.jl
2
+ # Algorithm 2.1 of Random Eigenvalues by Alan Edelman
3
+
4
+ # Experiment: Generate random samples from the normal distribution
5
+ # Plot: Histogram of random samples
6
+ # Theory: The normal distribution curve
7
+
8
+
9
+ # # Experiment
10
+ t = 1000000 # Trials
11
+ dx = 0.25 # binsize
12
+ v = randn (t,2 ) # samples
13
+ x = - 4 : dx: 4 # range
14
+
15
+ # # Plot
16
+ using Winston
17
+ module Plot3D
18
+ # Warning: the 3D interface is very new at the time
19
+ # of writing this and is likely to not be available
20
+ # and/or have changed
21
+ if Winston. output_surface == :gtk
22
+ include (Pkg. dir (" Winston" ," src" ," canvas3d_gtk.jl" ))
23
+ else
24
+ include (Pkg. dir (" Winston" ," src" ," canvas3d.jl" ))
25
+ end
26
+ end
27
+ edg1, edg2, count = hist2 (v, x- dx/ 2 )
28
+ cntrs = (first (x)+ dx/ 2 , last (x)- dx/ 2 , length (x)- 1 )
29
+ x,y = meshgrid (cntrs, cntrs)
30
+ Plot3D. plot3d (Plot3D. surf (x,y,count./ (t* dx^ 2 ) * 10 * length (cntrs)))
31
+ Plot3D. plot3d (Plot3D. surf (x,y,exp (- (x.^ 2 + y.^ 2 )/ 2 )/ (2 * pi ) * 10 * length (cntrs)))
Original file line number Diff line number Diff line change
1
+ # hist2d.jl
2
+ # Algorithm 2.2 of Random Eigenvalues by Alan Edelman
3
+
4
+ # see Base.hist2 for a simple implementation
You can’t perform that action at this time.
0 commit comments