Skip to content

Instantly share code, notes, and snippets.

@sansumbrella
Created November 17, 2011 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sansumbrella/1372000 to your computer and use it in GitHub Desktop.
Save sansumbrella/1372000 to your computer and use it in GitHub Desktop.
Find the gaussian value of a position
// loc = distance from center of distribution
float gaussian( float loc, float variance )
{
variance *= variance;
float a = loc * loc / ( 2.0 * variance );
float b = exp( -a );
float c = sqrt( PI * 2.0 * variance );
return b / c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment