Ejemplo n.º 1
0
        /// <summary>
        /// Generates a simulation cube of uniform or normal distributed samples
        /// </summary>
        /// <param name="nsims"> total number of simulations to be generated</param>
        /// <param name="dimension"> Dimensionality of the random vectos to be used</param>
        /// <param name="nsteps">Number of samples per dimension that need to be generated per simulation</param>

        public SimulationCube(UInt64 nsims, UInt64 dimension, UInt64 nsteps, DISTRIBUTION distribution = DISTRIBUTION.NORMAL)
        {
            number_of_sims           = nsims;
            number_of_dims           = dimension;
            number_of_steps          = nsteps;
            simulation_vector_length = number_of_dims * number_of_steps;

            GenerateUCube(distribution);
        }
Ejemplo n.º 2
0
        private void GenerateUCube(DISTRIBUTION d)
        {
            if (array != null)
            {
                return;
            }
            array = new double[number_of_sims][][];

            var uniform = new MathNet.Numerics.Random.MersenneTwister(seed);
            var normal  = new MathNet.Numerics.Distributions.Normal(0, 1, uniform);

            Func <double[]> rgn = null;

            switch (d)
            {
            case DISTRIBUTION.UNIFORM:
                rgn = () =>
                {
                    return(uniform.NextDoubles((int)number_of_steps));
                };
                break;

            case DISTRIBUTION.NORMAL:
                rgn = () =>
                {
                    double[] r = new double[number_of_steps];
                    normal.Samples(r);
                    return(r);
                };
                break;
            }

            for (UInt64 i = 0; i < number_of_sims; ++i)
            {
                array[i] = new double[number_of_dims][];
                for (UInt64 j = 0; j < number_of_dims; ++j)
                {
                    array[i][j] = rgn();
                }
            }
        }