astropy/astropy — pull request #1754 by keflavich (2013-11-06 10:07:50+00:00)
Title: Add mass functions to astropy.stats

This pull request is preliminary, but I want to get feedback from folks who have had success subclassing `scipy.stats.rv_continuous`, if any such exist.

Right now, I implement two simple analytic MFs: Salpeter & Kroupa. Both have the same nominal low-mass cutoff, which is a strict requirement of the distribution (so that the PDF integrates to 1).

My experience from testing these so far is that they are *very* slow for random sampling:
```
%timeit Salpeter.rvs(size=1000)
1 loops, best of 3: 3.25 s per loop
```
which means that more of the analytic versions of the hidden functions (e.g., `_ppf`) need to be implemented to make these MFs at all usable.

I've also found that the `rv_continuous` tools, while useful, are very inflexible in terms of how they define probability distributions, and those definitions are somewhat in conflict with the way MFs tend to get used (there is no sensible definition for a "location" or "scale" parameter for a power-law distribution, for example).

Anyway, I'm opening this up for feedback & discussion. @eteq has already provided some helpful feedback in terms of naming. If anyone has already implemented some of these functions but just never ported them to astropy, now's the time.