23
$\begingroup$

According to Wikipedia the beta probability distribution has two shape parameters: $\alpha$ and $\beta$.

When I call scipy.stats.beta.fit(x) in Python, where x is a bunch of numbers in the range $[0,1]$, 4 values are returned. This strikes me as odd.

After googling I found one of the return values must be 'location', since the third variable is 0 if I call scipy.stats.beta.fit(x, floc=0).

Does anyone know what the fourth variable is, and if the first two are $\alpha$ and $\beta$?

$\endgroup$
3
  • 1
    $\begingroup$ The documentation calls the last two "location" and "scale" parameters. Thus the fourth is the scale parameter. Location and scale have standard statistical meanings. One interpretation in this context is given explicitly in the NIST handbook. $\endgroup$
    – whuber
    Commented Sep 2, 2013 at 15:12
  • $\begingroup$ I'm having this exact same issue, but for some reason all my beta models tend to "hold water". For instance for stats.beta.fit([60,61,62,72]) I get (0.7313395126217731, 0.7153715263378897, 58.999999999999993, 3.3500998441036982). Any idea what I can do about this? $\endgroup$
    – TheChymera
    Commented Nov 16, 2014 at 16:15
  • 1
    $\begingroup$ Just adding this documentation for the generic continuous random variable fit method, which includes some examples using beta.fit(): docs.scipy.org/doc/scipy/reference/generated/… $\endgroup$
    – mathisfun
    Commented Apr 13, 2019 at 17:20

1 Answer 1

27
$\begingroup$

Despite an apparent lack of documentation on the output of beta.fit, it does output in the following order:

$\alpha$, $\beta$, loc (lower limit), scale (upper limit - lower limit)

$\endgroup$
4
  • $\begingroup$ Is it just spitting out the lower and upper limits based on the range of the data, or doing something else? $\endgroup$ Commented Aug 29, 2014 at 14:27
  • $\begingroup$ The limits are based on the probability distribution. ie. Normal distribution has no limits, but sample data rarely exceeds ~+/-3. Beta distribution has hard limits, with probability of 0 outside those limits. It is likely that your data won't reach the limits, depending on what you are modeling. In fact, trying to force those limits to match the range of the data can be problematic, as many beta distributions tend to zero probability at the limits. See this post for more on that issue. $\endgroup$
    – jdj081
    Commented Aug 29, 2014 at 16:06
  • 1
    $\begingroup$ Yes, I'm aware. Those limits are always 0 and 1. Hence: what are the upper and lower limits returned by this function, and how are they at all the same as "location" and "scale"? I guess I just don't understand this answer. $\endgroup$ Commented Aug 29, 2014 at 18:33
  • 5
    $\begingroup$ The way the beta distribution is defined, those limits are always 0 and 1. But the generalized beta distribution includes these two scaling factors. The data I model doesn't fall between 0 and 1, so I have to use those numbers. If your data is between 0 and 1, then those outputs should be very close to 0 and 1. If you know your limits are 0 and 1, you can force those with the floc=0 and fscale=1 kwargs. You will still get those outputs, but they will be identical to what you force them to be. And it will likely change your alpha and beta values. $\endgroup$
    – jdj081
    Commented Aug 29, 2014 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.