I want to create a large array of random numbers drawn from the gaussian distribution. I found dlarnv, but I am not sure how to use it in Swift. Specifically, the type signature XCode shows is as follows:
dlarnv_(
__idist: UnsafeMutablePointer<__CLPK_integer>,
__iseed: UnsafeMutablePointer<__CLPK_integer>,
__n: UnsafeMutablePointer<__CLPK_integer>,
__x: UnsafeMutablePointer<__CLPK_doublereal>
)
How do I use this to fill an array with single precision floating point numbers? This is how far I have gotten:
n = 10000
var data: [Float]
data.reserveCapacity(n)
data
dlarnv_(
3, // for normal distribution
seed, // not sure how to seed
n,
data, // not sure how to pass a pointer
)
Using
dlarnv_is much faster than usingGameplayKit