LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview function similar to numpy.random.normal

Solved!
Go to solution

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

0 Kudos
Message 1 of 5
(5,338 Views)

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.

Message 2 of 5
(5,315 Views)
Solution
Accepted by topic author dougbockILT

...and here's what it looks like

 

-Kevin P

 

image.pnggaussian distribution.png

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 3 of 5
(5,296 Views)

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.

Message 4 of 5
(5,281 Views)

The first function (maybe both) used by Kevin is available as PtByPt function. You can use that to get single points.

0 Kudos
Message 5 of 5
(5,234 Views)