`stats.norminvgauss` incorrect implementation?
See original GitHub issueHi,
Mentioned in the latest release of TensorFlow Probability, it has been noted that scipy.stats.norminvgauss
has not been implemented in the same way as R or the original mathematical paper.
It seems the loc
and scale
parameters should actually be mu
and delta
. Is there a way to update this so that non-standard cases (other than loc=0, scale =1
) make mathematical sense?
Note that `scipy.stats.norminvgauss` implements the distribution as a
location-scale family. However, in the original paper, and other
implementations (such as R) do not implement it this way. Thus the
`scale` parameters here and scipy don't match unless `scale = 1`.
Warning: As mentioned above, this distribution is __not__ a location-scale
family.
Docs: https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/NormalInverseGaussian
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
scipy.stats.norminvgauss — SciPy v1.9.3 Manual
A Normal Inverse Gaussian continuous random variable. As an instance of the rv_continuous class, norminvgauss object inherits from it a collection of generic ......
Read more >oryx.distributions.NormalInverseGaussian | Oryx | TensorFlow
Python bool describing behavior when a stat is undefined. Stats return +/- infinity when it makes sense. E.g., the variance of a Cauchy...
Read more >SciPy 1.8.0 Release Notes
A new scipy.stats.sampling submodule that leverages the UNU.RAN C library to sample from ... #14568: `stats.norminvgauss` incorrect implementation?
Read more >Scipy/Scipy: Scipy 1.1.0 - NASA/ADS
The method switches between two implementations depending on the problem ... Added the normal inverse Gaussian distribution as scipy.stats.norminvgauss.
Read more >scipy.stats._continuous_distns — Copulas 0.6.0 documentation
The location-scale-based parameterization implemented in SciPy is based on [2]_, where :math:`a ... "Values replaced by NaN to avoid incorrect results.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mdhaber Thanks! That works really well!
Very close, but don’t use
norminvg
to calculate the PPF and ISF. The functions will only be evaluated atx = tol/10
, so you can code in correct values yourself. It is not very sensitive to these values being super accurate - e.g., for PPF, return any valuex
at whichnorminvg.cdf(x)
is very small (ideallytol/10
).Something like
This will make
NumericalInverseHermite
form an approximationH
of the inverse ofnorminvg.cdf
that is valid between -2 and 2. The round-trip tolerance (i.e.abs(x - norminvg.cdf(H(x)))
) will be controlled at mesh points and midpoints between mesh points totol=1e-6
.