06-21-2019 09:13 AM
I am trying to generate random numbers with an underlying gaussian distribution, similar to the output of the numpy (python) function numpy.random.normal.
Specifically, I want to supply a mean and variance, and have the function return numbers close to the mean with a higher probability than those further away.
I am at a complete loss about this. None of the supplied 'Gausian VIs' seem to be able to do this and I dont know how to implement his myself.
Thanks. Doug
Solved! Go to Solution.
06-21-2019 09:35 AM - edited 06-21-2019 09:37 AM
Gaussian White Noise PtByPt.vi and Gaussian White Noise.vi both have a standard deviation as input.
AFAIK, variance is (std.dev)^2... Std. Dev is sqrt(variance).
The mean value can simply be added to the output. Normally, the noise is centered around 0, which is the mean.
06-21-2019 09:58 AM
...and here's what it looks like
-Kevin P
06-21-2019 10:39 AM
You did not say if you want one random number at a time or an entire array full of them. The above solution gives you an array.
To generate a single such random number, you could write your own subVI using the Box-Muller algorithm. It takes pairs of even distributed random numbers (0..1) to obtain one (or even two) normalized random numbers that can be shifted and scaled for the desired mean and standard deviation. Your subVI would take mean and stdev as inputs and return a corresponding random value.
06-24-2019 01:35 AM
The first function (maybe both) used by Kevin is available as PtByPt function. You can use that to get single points.