You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In herbert_core\utilities\math\randpoisson.m, the while loop in lines 25-28 should be a do-while loop. For arg lam==0, this gives a return value of -1. With the correction to do-while, it gives 0, which agrees with the native MATLAB poissrnd. Using the correct form from the Numerical Recipes versions for F90 and C, also get 0 (but not F77 which is unusable as it contains a goto :-)).
Alternative fixes are:
code the do-while loop
use native MATLAB poissrnd
The latter would be easier as then we do not need to test the result (of course MATLAB is always right!) whereas for randpoisson we should add tests to ensure it is correct.
The text was updated successfully, but these errors were encountered:
Toby added this implementation for specific performance reasons managing issues with the then-available alternatives.
If the function is replaced suitable performance metrics should be generated to prove the native MATLAB implementation (which presumably didn't exist when this function was created in 2006) is at least as performant.
The problem is that poissrnd is a function in the statistics and machine learning toolbox. We should only be using matlab functions that are in the main Matlab, and not in any of the toolboxes because we cannot count on users having particular toolboxes.
In herbert_core\utilities\math\randpoisson.m, the while loop in lines 25-28 should be a do-while loop. For arg lam==0, this gives a return value of -1. With the correction to do-while, it gives 0, which agrees with the native MATLAB poissrnd. Using the correct form from the Numerical Recipes versions for F90 and C, also get 0 (but not F77 which is unusable as it contains a goto :-)).
Alternative fixes are:
The latter would be easier as then we do not need to test the result (of course MATLAB is always right!) whereas for randpoisson we should add tests to ensure it is correct.
The text was updated successfully, but these errors were encountered: