Reputation: 41
In J, I know that we can generate a list of uniform random numbers, and use some sort of inverse function to have a list of normal distribution number. But is there a quick way to achieve this?
Upvotes: 1
Views: 164
Reputation: 426
How to generate, say, a 3*4-matrix B with elements b distributed as b ~ N(5,0.9^2)
load 'stats/distribs'
B=. 5 0.9 rnorm 3 4
load 'math/mt'
NB. real b ~ N(5,0.9^2)
B=. 5 0.9 randnf_mt_ 3 4
NB. complex b ~ N(5+i*6,0.9^2)
B=. 5j6 0.9 randnc_mt_ 3 4
NB. quaternion b ~ N(5+i*6+j*7+k*8,0.9^2)
B=. 5j6 7j8 0.9 randnq_mt_ 3 4
Both uses Box-Muller approach.
Upvotes: 3