@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
14 lines (12 loc) • 807 B
JavaScript
/**
* This is not the standard gaussian.
* It lacks the normalization factor, standard gaussian would be weighted by `1 / √(2π * variance)`
* @param {number} sigma Standard deviation. Distance from mean. Represents the "width" of the Gaussian-like curve. Note: The parameter is named `sigma`, but its placement in the formula means it scales inversely to the usual effect of sigma.
* @param {number} v Variance. Represents the "height" or "amplitude" of the curve, but at a distance from the mean. Larger variance values result in larger function values further away from the mean (0).
* @returns {number} Ranges from 0 to 1 (exclusive of 0)
*/
export function gaussian(sigma, v) {
const v2 = v * v;
const sigma2 = sigma * sigma;
return Math.exp(- v2 / (2 * sigma2));
}