Probability-Distributions-for-PHP icon indicating copy to clipboard operation
Probability-Distributions-for-PHP copied to clipboard

Parameters in Gamma distribution

Open mossadal opened this issue 7 years ago • 5 comments

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?

mossadal avatar Jul 01 '17 22:07 mossadal

@gburtini Any thoughts on this? I'd like to finish the Gamma implementation (and chi^2 as a special case) with a pull request.

mossadal avatar Jul 19 '17 22:07 mossadal

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. :)

gburtini avatar Jul 20 '17 22:07 gburtini

Thanks, I'll get to this within the next few days.

mossadal avatar Jul 24 '17 21:07 mossadal

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

gustawdaniel avatar Jan 23 '19 03:01 gustawdaniel

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

gburtini avatar Jan 24 '19 20:01 gburtini