Пример #1
0
        public double SampleMean(IDistribution distribution)
        {
            sample = SampleGenerator.GenerateSample(distribution, n);

            double sum = 0;

            foreach (double x in sample)
            {
                sum += x;
            }

            return(sum / n);
        }
Пример #2
0
        public double Next(RandomBSV rand)
        {
            List <double> a = SampleGenerator.GenerateSample(rand, N);

            double x = 0.0;

            foreach (double element in a)
            {
                x += element;
            }

            x -= N / 2;
            x *= Math.Sqrt(12.0 / N);

            return(m + Math.Sqrt(s) * x);
        }
Пример #3
0
        public double SampleCorrelation(IDistribution distribution)
        {
            Tuple <List <double>, List <double> > samples
                = SampleGenerator.GenerateSubsamples(distribution, n);

            double
                _x = samples.Item1.Average(),
                _y = samples.Item2.Average();

            double
                numerator   = 0.0,
                denominator = 0.0;

            for (int i = 0; i < n / 2; i++)
            {
                numerator   += (samples.Item1[i] - _x) * (samples.Item2[i] - _y);
                denominator += Math.Pow(samples.Item1[i] - _x, 2) * Math.Pow(samples.Item2[i] - _y, 2);
            }

            denominator = Math.Sqrt(denominator);
            return(numerator / denominator);
        }