function factory( r, p ) {
	if (
		isnan( r ) ||
		isnan( p ) ||
		r <= 0.0 ||
		p <= 0.0 ||
		p > 1.0
	) {
		return constantFunction( NaN );
	}
	return pmf;

	/**
	* Evaluates the probability mass function (PMF) for a negative binomial distribution.
	*
	* @private
	* @param {number} x - input value
	* @returns {Probability} evaluated PMF
	*
	* @example
	* var y = pmf( 2.0 );
	* // returns <number>
	*/
	function pmf( x ) {
		if ( isnan( x ) ) {
			return NaN;
		}
		if ( !isNonNegativeInteger( x ) ) {
			return 0.0;
		}
		return ( p / ( r + x ) ) * ibetaDerivative( p, r, x + 1.0 );
	}
}
Returns a function for evaluating the probability mass function (PMF) for a negative binomial distribution with number of successes until experiment is stopped `r` and success probability `p`.

@param {PositiveNumber} r - number of successes until experiment is stopped
@param {Probability} p - success probability
@returns {Function} PMF

@example
var pmf = factory( 10, 0.5 );
var y = pmf( 3.0 );
// returns ~0.027

y = pmf( 5.0 );
// returns ~0.061