| 123456789101112131415161718192021222324252627282930313233343536 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace XdCxRhDW.Framework{    public static class RandomHelper    {        //标准正态分布        public static double Normal()        {            Random aa = new Random(Guid.NewGuid().ToString().GetHashCode());            double s = 0, u = 0, v = 0;            while (s > 1 || s == 0)            {                u = aa.NextDouble() * 2 - 1;                v = aa.NextDouble() * 2 - 1;                s = u * u + v * v;            }            var z = Math.Sqrt(-2 * Math.Log(s) / s) * u;            return (z);        }        //符合要求的正态分布随机数        public static double Normal(double miu, double sigma)        {            var z = Normal() * sigma + miu;            return (z);        }    }}
 |