I have data and I want to ascertain whether it is beta or gamma distribution.

Once I know what the distribution is, how do I find out what the parameters are?

  • 8
    $\begingroup$ Can you say anything about your data, such as where they come from, or if they're bound by 0 & 1? $\endgroup$ May 11, 2012 at 16:49
  • 5
    $\begingroup$ Why do you think it's either gamma or beta distributed? $\endgroup$
    – jbowman
    May 11, 2012 at 18:18
  • 2
    $\begingroup$ Have you looked at qqplots of your data against those densities? $\endgroup$
    – Seth
    May 11, 2012 at 18:29
  • 3
    $\begingroup$ The Beta distribution is restricted to $(0,1)$ so it should be rather obvious when looking at your data, assuming those are the only two possibilities.... $\endgroup$
    – Xi'an
    May 12, 2012 at 19:37

1 Answer 1


You can use the free statistical program R, available at http://www.r-project.org/, to analyze your data. You state that you want to determine how your data are distributed. You guess that your data either conform to a beta or a gamma distribution. You provide no information about your data and do not speculate that it could conform to one of the many other probability distribution types, so I'll just briefly discuss the two distributions that you mention in my answer. I suppose the most logical thing to do first would be to simply plot your data on a histogram or density plot to facilitate visual inspection.

Example 1: Beta Distribution

The beta distribution is a family of continuous probability distributions defined on the interval (0, 1).

You provide no example data in your question, so we will have to make some up for this example. First, let's make some randomly generated dummy data that conform to a beta distribution. We can use the rbeta() command to do this. Type help(rbeta) into R to learn how to use this function.

## Generate 10,000 data points and save them as an object called "temp".
temp <- rbeta(10000, shape1 = 1, shape2 = 1, ncp = 0)

Now, let's double check that our data are bound by zero and one. We can use the summary() command to do this.

## Find maximum and minimum value of the data.

Now, let's plot the data on a histogram for visual inspection.

## Plot the data on a histogram.

You could alternatively make a density plot of the data, which for practical purposes is the same thing.

## Make density plot.

I suppose you can take the mean and variance of your data and use them to calculate the parameters of a beta distribution. (Before jumping to this step, you should probably do more descriptive analyses, including looking at the qqplots as suggested by Seth, above). The below function, copied directly from Max's example on this page, should provide estimates of the parameters.

## Calculate mean and variance of the data.
mu <- mean(temp)
var <- var(temp)

## Define function to estimate parameters of a beta distribution.
estBetaParams <- function(mu, var) {
  alpha <- ((1 - mu) / var - 1 / mu) * mu ^ 2
  beta <- alpha * (1 / mu - 1)
  return(params = list(alpha = alpha, beta = beta))

## Apply function to your data.
estBetaParams(mu, var)

Example 2: Gamma Distribution

The gamma distribution is a two-parameter family of continuous probability distributions.

First, let's make some randomly generated dummy data that conform to a gamma distribution. We can use the rgamma() command to do this.

## Generate 10,000 data points and save them as an object called "temp".
temp <- rgamma(10000, shape = 1, rate = 10, scale = 1/rate)

## Plot the data on a histogram for visual inspection.

To estimate the gamma distribution parameters, you can use the MASS library, explained at this website. After installing and loading the MASS library into R, type help(fitdistr) for more information.

Suggested Further Reading

The following document explains how to do everything in much more detail. Note that I am not a statistician so perhaps you should take my advice with a grain of salt. However, I think I am more or less leading you in the correct direction. The below document will show you how to make qqplots of your data against those densities, as suggested by Seth above.

  1. Ricci, V. Fitting distributions with R. February 2005.
  • $\begingroup$ (+1) Maximum likelihood estimation in the gamma case is doable; for large sample sizes, the much simpler method of moments should work reasonably well. $\endgroup$
    – cardinal
    May 13, 2012 at 23:22
  • $\begingroup$ beta is defined on the interval $(0,1)$ or $[0,1]$ ? $\endgroup$
    – juanpablo
    Aug 12, 2013 at 14:21
  • $\begingroup$ @juanpablo apparently both definitions exist (from Wikipedia): "This definition includes both ends x = 0 and x = 1, which is consistent with definitions for other continuous distributions (...) However, the inclusion of x = 0 and x = 1 does not work for α, β < 1; accordingly, several other authors choose to exclude the ends x = 0 and x = 1, (so that the two ends are not actually part of the domain of the density function) and consider instead 0 < x < 1." $\endgroup$ Apr 24, 2018 at 8:44

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