public static float GetRandom(float inMin, float inMax, System.Random inRandom) { if ((double)inMin > (double)inMax) { inMax = inMax; inMin = inMax; } return(inMin + (inMax - inMin) * RandomUtility.GetRandom01(inRandom)); }
public static float GetRandomRoundedToStep(float inMin, float inMax, int nSteps) { //Debug.AssertFormat((nSteps > 1 ? 1 : 0) != 0, "Jason - Number of steps {0} is too few for GetRandomRoundedToStep method.", (object)nSteps); if ((double)inMin > (double)inMax) { float num = inMin; inMin = inMax; inMax = num; } float num1 = inMax - inMin; float num2 = inMin + num1 * (float)Math.Round(RandomUtility.GetRandom01() * (float)nSteps) / (float)nSteps; //Debug.AssertFormat(((double)num2 > (double)inMax ? 0 : ((double)num2 >= (double)inMin ? 1 : 0)) != 0, "Jason - Error in GetRandomRoundedToStep. Output {0} is outside requested range {1} - {2}", (object)num2, (object)inMin, (object)inMax); return(num2); }
public static float GetRandom01() { return(RandomUtility.GetRandom01(RandomUtility.globalRandomInstance)); }
public static float GetRandomNormallyDistributed01() { return((float)Math.Sqrt(-2f * (float)Math.Log(RandomUtility.GetRandom01())) * (float)Math.Sin(6.283185f * RandomUtility.GetRandom01())); }