public static FloatType ShoreStandardNormalQuantileFunction <FloatType>(random.Probability p) where FloatType : unmanaged { /* * see: * https://en.wikipedia.org/wiki/Normal_distribution#Numerical_approximations_for_the_normal_CDF */ double r, epsilon; bool condition = p.GetValue() >= 0.5; r = condition ? p : 1 - p; epsilon = condition ? 1.0 : 0.0; return((FloatType)(object)(epsilon * 5.5556 * (1 - Math.Pow(r / (1 - r), 0.1186)))); }