question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

do CDF inversion methods have to be public?

See original GitHub issue

@chrisb83, @mdhaber, @tirthasheshpatel I had completely missed the API changes to add NumericalInverseHermite and other public classes listed in http://scipy.github.io/devdocs/reference/stats.html#random-variate-generation-cdf-inversion. Was that discussed on the mailing list, and do these things have to be public?

My impression is that it’s a complex API that is quite unlike other APIs in scipy.stats. They take distribution objects that are not the regular stats distributions:

An instance of a class with pdf and dpdf methods.

It looks to me at first glance that this should be private infrastructure which supports improved RVS generation in the regular distribution classes?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:31 (31 by maintainers)

github_iconTop GitHub Comments

1reaction
tirthasheshpatelcommented, Oct 28, 2021

For complicated pdf/cdf functions where you can’t just calculate these parameters analytically, it seems that would require drawing a lot of samples, estimating center and mode, and then feeding those back in. And then if you tweak domain, you have to remember to update these other params. Is that actually usable?

Most distributions are unimodal. One could use the optimize submodule to find the mode of the PDF (even for bounded/truncated distributions) in that case. In other cases, one could either analytically calculate the mode or give a value close to the actual mode (i.e. approximate the mode).

1reaction
chrisb83commented, Oct 18, 2021

rvs_ratio_uniforms seems to be a problem as well, it does a very similar thing to NaiveRatioUniforms as far as I can tell from the docs - it should probably also be deprecated

Yes, NaiveRatioUniforms offers the same functionality as a special case using the common interface that Tirth implemented .We initially wanted to deprecate rvs_ratio_uniforms after adding NaiveRatioUniforms. We then decided to wait since the former is still faster (about 6x if I remember correctly). We can still deprecate it right away in my view. For a lot of distributions, NumericalInverseHermite or NumericalInversePolynomial offer faster alternatives.

Read more comments on GitHub >

github_iconTop Results From Across the Web

quantiles - Inverse transform sampling - CDF is not invertible
Actually i am interested to learn about existing approaches to deal with the CDF, which is either not invertible, or hard to invert....
Read more >
Inverse transform sampling - Wikipedia
Inverse transform sampling is a basic method for pseudo-random number sampling, i.e., for generating sample numbers at random from any probability ...
Read more >
13.3 Sampling Random Variables - PBR Book
The inversion method uses one or more uniform random variables and maps them to random variables from the desired distribution. To explain how...
Read more >
how to generate data from a distribution whose cdf is not in ...
You can do it the following way, using the inverse cdf method with the empirical cdf (don't need the analytically derived cdf):
Read more >
scipy.stats.rv_continuous — SciPy v1.9.3 Manual
Public methods of an instance of a distribution class (e.g., pdf , cdf ) ... if the inverse cdf can expressed in an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found