Function to generate a random distribution of body sizes by drawing from a gamma distribution. Shape and rate parameters of the gamma are estimated from the empirical data.

1 | ```
size_gamma(speciesData = rnorm(50, mean = 100, sd = 1))
``` |

`speciesData` |
a vector of body sizes or other trait measurements of species. All values must be positive real numbers. |

Returns a vector of simulated body sizes as the same length as speciesData.

The shape and rate parameters are estimated from the real data using the maximum likelihood estimators generated from the fitdr function in the MASS library. The flexible gamma distribution can be fit to a variety of normal, log-normal, and exponential distributions that are typical for trait data measured on a continuous non-negative scale.

`fitdistr`

in the MASS library.

1 | ```
obsOverlap <- size_gamma(speciesData=rnorm(50,mean=100,sd=1))
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.