Ejemplo n.º 1
0
 private void PopulateQuantileValues()
 {
     for (int k = 0; k < GetNumber() - 1; ++k)
     {
         _quantileValues[k] = (double)((Double)MathsUtil.BinomialCoefficient(k, GetNumber())
                                       * Math.Pow(_p.GetValue(), k)
                                       * Math.Pow(_p.GetInverseEventProb().GetValue(), GetNumber() - k));
         if (k > 0)
         {
             _quantileValues[k] += _quantileValues[k - 1];
         }
     }
     _quantileValues[GetNumber() - 1] = 1.0;
 }
Ejemplo n.º 2
0
        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))));
        }
Ejemplo n.º 3
0
        public HypergeometricDistribution(Probability p, int min, int max, int N)
            : base(min, max)
        {
            _N = N;
            if (N < min - max + 1)
            {
                throw new System.ArgumentOutOfRangeException("Nope, RTFM.");
            }

            /*
             * we have to have N*p an integer
             * so we may have to tweak p a bit
             */
            int j = (int)(_N * p.GetValue());

            _p = new Probability((double)j / _N);
            PopulateQuantileValues();
        }
Ejemplo n.º 4
0
 override public double TheoreticalMean()
 {
     return(_p.GetValue());
 }