Skip to content

Instantly share code, notes, and snippets.

@ciscoslot
Created April 4, 2016 13:24
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciscoslot/d2d57b351e4852d5e03a30663fdcd87b to your computer and use it in GitHub Desktop.
Save ciscoslot/d2d57b351e4852d5e03a30663fdcd87b to your computer and use it in GitHub Desktop.
Unity Gaussian Random
using UnityEngine;
public static class GaussianRandom
{
public static float generateNormalRandom(float mu, float sigma)
{
float rand1 = Random.Range(0.0f, 1.0f);
float rand2 = Random.Range(0.0f, 1.0f);
float n = Mathf.Sqrt(-2.0f * Mathf.Log(rand1)) * Mathf.Cos((2.0f * Mathf.PI) * rand2);
return (mu + sigma * n);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment