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

	/**
	* Evaluates the moment-generating function (MGF) for a negative binomial distribution.
	*
	* @private
	* @param {number} t - input value
	* @returns {number} evaluated MGF
	*
	* @example
	* var y = mgf( 0.5 );
	* // returns <number>
	*/
	function mgf( t ) {
		if ( t >= -ln( p ) ) {
			return NaN;
		}
		return pow( ( (1.0 - p) * exp( t ) ) / ( 1.0 - (p * exp( t )) ), r );
	}
}
Returns a function for evaluating the moment-generating function (MGF) of a negative binomial distribution.

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

@example
var mgf = factory( 4.3, 0.4 );
var y = mgf( 0.2 );
// returns ~4.696