distributions
distributions copied to clipboard
Adding Pareto distribution and 'Truncated' distribution.
Hey! I was messing around with your library, and I really like it so far. I've been working on a side project and I was trying to make a Pareto distribution, along with a "wrapper" which does the math to truncate a distribution. I'm a little stuck on some of the math, though. I'd like to get this into a mergeable state- any thoughts? Thanks!
This is nice. Could you provide some more information about what you think is missing?
From a quick look: Pareto median and variance is missing, it looks like they are easy to implement http://en.wikipedia.org/wiki/Pareto_distribution
The Truncated median should just be the median of the underlying distribution, unless the median is outside the [a, b) interval. In that case I think it is safe to assume it is one the edge, so pdf(a) > pdf(b) ? a : b should do it.
The mean and variance I going to be hard, maybe \int_a^x x * pdf(t) dt and \int_a^x x^2 * pdf(t) dt could be implemented for each distribution class but that seams like a lot of work. I think just throwing an error indicating it is not implemented is good.
I'm not so sure about the defaults for the truncated distribution, I think that can be done smarter. I will have to think about it / look it up.
Some of the errors should likely be RangeError and not TypeError.
Tests are missing, just do like the other tests that is already exists. And be sure to use a reference implementation for the output values and not just this implementation. Preferably write a comment describing where it comes from and how to recalculate it.