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

	/**
	* Evaluates the moment-generating function (MGF) for a binomial distribution.
	*
	* @private
	* @param {number} t - input value
	* @returns {number} evaluated MGF
	*
	* @example
	* var y = mgf( 0.5 );
	* // returns <number>
	*/
	function mgf( t ) {
		var base;
		if ( isnan( t ) ) {
			return NaN;
		}
		base = 1.0 - p + (p * exp(t));
		return pow( base, n );
	}
}
Returns a function for evaluating the moment-generating function (MGF) of a binomial distribution with number of trials `n` and success probability `p`.

@param {NonNegativeInteger} n - number of trials
@param {Probability} p - success probability
@returns {Function} MGF

@example
var mgf = factory( 10, 0.5 );
var y = mgf( 0.3 );
// returns ~5.013