Skip to content

Commit e829d96

Browse files
committed
jeff doesn't like meshgrid, so we we switch to comprehensions
1 parent d80af76 commit e829d96

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

demos/book/2/bellcurve2.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88

99
## Experiment
10-
t = 1000000 # Trials
10+
t = 10000 # Trials
1111
dx = 0.25 # binsize
1212
v = randn(t,2) # samples
1313
x = -4:dx:4 # range
1414

1515
## Plot
1616
using Winston
1717
module Plot3D
18+
using Winston
1819
# Warning: the 3D interface is very new at the time
1920
# of writing this and is likely to not be available
2021
# and/or have changed
@@ -25,7 +26,10 @@ module Plot3D
2526
end
2627
end
2728
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)))
29+
#cntrs = ((first(x)+dx/2), (last(x)-dx/2), length(x)-1)
30+
#x,y = meshgrid(cntrs, cntrs)
31+
cntrs = (first(x)+dx/2):dx:(last(x)-dx/2)
32+
x = Float64[x for x = cntrs, y = cntrs]
33+
y = Float64[y for x = cntrs, y = cntrs]
34+
Plot3D.plot3d(Plot3D.surf(x,count./(t*dx^2) *50,y))
35+
Plot3D.plot3d(Plot3D.surf(x,exp(-(x.^2+y.^2)/2)/(2*pi) *50,y))

0 commit comments

Comments
 (0)