Probability-Distributions-for-PHP
Probability-Distributions-for-PHP copied to clipboard
Parameters in Gamma distribution
The code for the Gamma distribution is very incomplete -- the class only basically only contains code for random number generation from a Gamma distribution.
I implemented the pdf, cdf, icdf as well as unit tests, and noticed that the parameters are named $shape and $rate, which would seem congruent with alpha and beta as described in Wikipedia's description of the Gamma distribution.
Running the unit tests on Gamma::draw gives a sample of points that seem to be Gamma(alpha, 1/beta) distributed, suggesting that $rate is really $scale.
What is your preference? Changing the parameters to $shape and $scale or keeping $shape and $rate and correct Gamma::draw?
@gburtini Any thoughts on this? I'd like to finish the Gamma implementation (and chi^2 as a special case) with a pull request.
Hey @mossadal,
Sorry, I hadn't seen the issue. Please feel free to make this decision yourself. In general, I tried to remain congruent with Wikipedia's "first" expository parametrization, but this is totally arbitrary and it does not surprise me that I made an error in this particular case. :)
Thanks, I'll get to this within the next few days.
In my opinion, selecting one convention is rather important and I would like to select convention presented in Mathematica from Wolfram Research. Reasons:
- they have a great tool to calculations for free - wolframalpha.com
- they have a consistent base of knowledge maintained by a commercial company
- on Wikipedia, you can find different conventions, MathoWorld has one version
I would like to change the interface of Gamma but worry about backward compatibility. Any versioning is there? I added version 1.0 to my last commit, we can break compatibility if a community will want it.
This issue is similar to #32
Yep, I agree - let's go with the Mathematica standard.
Feel free to institute semver in your next PR if we haven't already done that. I have it on my long term "like to do" list to come back to this repo. and really improve its engineering decisions.
Thanks for chmining in @gustawdaniel