Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a random number from normal distribution in J

Tags:

j

In J programming: I know how to get a linear random number.

? 5#10
1 3 3 4 7

But how to get a random number from normal distribution, e.g. N(0,1)? Thanks!

like image 933
Ellie Y Avatar asked Dec 05 '25 07:12

Ellie Y


2 Answers

I think you're looking for normalrand in the stats package:

   load 'stats'
   normalrand 5
_0.514477 1.23645 _0.353373 _0.522193 1.23505
like image 144
Daniel Lyons Avatar answered Dec 10 '25 06:12

Daniel Lyons


See also the stats/distribs addon

   load 'stats/distrib'
   rnorm 4
_0.486091 _0.339021 1.50653 0.19308
   10 2 rnorm 4    NB. from distribution N(10,2)
10.0588 11.0472 13.6208 8.78888
like image 35
Tikkanz Avatar answered Dec 10 '25 05:12

Tikkanz