MastodonC / kixi.stats

A library of statistical distribution sampling and transducing functions
https://cljdoc.xyz/d/kixi/stats
Eclipse Public License 1.0
355 stars 17 forks source link

Implement PQuantile for the Uniform distribution #34

Closed bombaywalla closed 3 years ago

bombaywalla commented 4 years ago

I implemented PQuantile for Uniform. In implementing quantile, I chose to return a for 0.0 and b for 1.0 to make quantile symmetric with cdf.

I added a cdf-and-quantile-are-inverses test for Uniform. In implementing the test, I realized that a < b and so copied the generator you had in the uniform-does-not-exceed-bounds test and made it a helper function gen-two-ascending-ints. I did not reuse the helper function uniform-does-not-exceed-bounds so as to keep the diffs small and to not disturb existing code. But happy to do the refactor if you're okay with it.

I also added an assert for a < b. However that caused other tests to fail. So, for now I have commented out the assert. After investigation, I found that several of the tests using the Uniform distribution do not guarantee that a < b. I am happy to fix those if you are okay with it.

During the investigation, I also noticed that in some tests for Normal, the scale parameter could be negative. Is that okay? Or should it be > 0. Noticed a similar issue with a LogNormal test. Again happy to fix these if you'd like.

In order to keep the PRs small and focussed, I suggest that the test bugfixes be in a different PR. But happy to add those to this PR if you'd prefer. Just let me know.

Also updated test.check.

bombaywalla commented 4 years ago

See PR #35 for the improvements to the tests suggested previously in this PR.

bombaywalla commented 4 years ago

I rebased this based on your merging PR #35. Should be good to go. Please review and merge if okay.