Jump to content

Bug/Documentation Error in Continuous Random VI: Gamma Random

Recommended Posts

The Gamma Random generator has two parameter inputs in addition to the number of sample: b and c

According to the help, which I paste here for the record:




b is the scale parameter and c the shape parameter of the Gamma distribution.

However, if you do that, the generated RV are bogus, because it turns out that b is the shape parameter and c is the scale parameter, as defined for instance on Wikipedia:


This can be easily verified by generating a large number of RV and comparing their normalized histogram with the functional form above.


Tested in LabVIEW 2021 SP1f3 on Windows 10 64 bit


Link to comment

A somewhat related bug in this function is that for certain parameters, it will fail to compute a random variable and instead of returning an error, will return "NaN" for the values and an error code of 0. So not only do you have to use a custom code handling snippet (no error cluster output as those things date back from Colonel Kodosky times), but also check for NaN outputs.

In any case, NaN output is clearly not a valid one, because it is due to a failure of finding a solution to CDF(x) = cte in this subVI:


where the unconnected error from the subVI is clearly non zero when there is a failure to find a solution (positive/negative bracket for the root):


Since I am not planning to go past LabVIEW 2021, I can fix that in my repo, but this is a remnant of olden times which will keep biting the likes of SpaceX, Blue Origin and others, who are planning to send human to Mars (hopefully this nonsense will stop earlier rather than later).

Link to comment

Another fun bug of this function is that it arbitrarily cuts off generation at 10,000:



Why not? It always spices up debugging...

(the revision history shows: rev. 2 Sun, Sep 25, 1994 12:46:16 PM greggf)


Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.