From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Bug Report: Rate parameter 0 returns an error in Random Poisson Variable.vi

There is still a bug in the Random Poisson Variable.vi (Mathematics>>Probability & Statistics>>Probability palette) in LabVIEW 2015f2:

 

if you enter a value of lambda (rate parameter), the output is empty (no value is returned) and the VI returns an error -20069, which supposedly has the following reason:

 

Analysis:  The number of samples must be greater than or equal to four.

 

First of all, there is absolutely no sample number issue, and second, a rate parameter of 0 is perfectly legit. The returned values should all be 0.

 

Tested in LabVIEW 2015f2 64 bits in Windows 7

0 Kudos
Message 1 of 5
(2,868 Views)

The Help for the Error Message is incomplete (true of a number of LabVIEW Error Messages).  The actual error, defined in NI_Gmath.lvlib, is "invalid math domain" (which is -20069).  In this case, it is generated because the rate of a Poisson Process must be >0, so a value of 0 is an error, an "invalid math domain".

 

Bob Schor

0 Kudos
Message 2 of 5
(2,839 Views)

https://en.wikipedia.org/wiki/Poisson_distribution

 

It wouldn't make much sense to have the result you desire.  If all values of k are 0, there's 0 probability it will ever happen at any value.  That leaves you with a CDF that's broken.  If you use the value of 1, do you still get the error?

 

As you're using a value that, by definition, isn't a legitimate value, it's not all that surprising you get an error thrown.  It'd be more unexpected that it'd give arbitrary results for an invalid value.  If it does have issues with 1, 2, and 3 as the analysis you listed suggests, that would be something to take a look at.  If it's only for 0, that's just how the RV works.

0 Kudos
Message 3 of 5
(2,821 Views)

The Poisson distribution Poi(k, lambda) is the probability to observe n random and independent counts within a given interval, knowing what the mean number of count is (lambda in the Wikipedia article, same as the name of the VI's rate parameter).

It is perfectly fine, even if the article in Wikipedia states that  lambda > 0, to consider the case where this average number is 0.

Indeed, in this case:

 

Pr(X = k) = 1 for k = 0, 0 otherwise.

E(X) = 0

E(Xˆ2) = 0 and in fact all moments are 0.

 

However, it appears that I am in the minority in believing that this is a legit situation.

Mathematica refuses to compute a random variate for a Poisson distribution of parameter 0, even though their definition only states that lambda should be positive (and not strictly positive as it turns out to be the case in their implementation).

Python numpy is however perfectly OK with lambda = 0.

 

I suppose this is all due to the fact that the formula for skewness and kurtosis break down for a value of zero, although that is not involved in the computation of a random variate.

In fact, if you remove the test lambda > 0 in the actual VI, the returned result is perfectly fine (at least according to my point of view): all zeros.

 

0 Kudos
Message 4 of 5
(2,810 Views)

That VI was last modifed in 1994:

 

rev. 6 Sun, Sep 25, 1994 12:38:56 PM greggf VI was converted from LabVIEW version 3.1b4 to LabVIEW version 3.1.

 

I know have a new version removing this lambda > 0 limitation in my own folder.

 

0 Kudos
Message 5 of 5
(2,801 Views)