private static double[] GenerateRandom(DistributionsEvaluator evaluator, Dictionary <string, DistributionSettings> univariateDistributions, Dictionary <string[], MultivariateDistributionSettings> multivariateDistributions, int samples)
        {
            double[] random = new double[samples];
            var      order  = evaluator.Parameters;

            MultivariateGenerator generator = new MultivariateGenerator(order, univariateDistributions, multivariateDistributions);

            Parallel.For(0, samples, i =>
            {
                Random rnd = Rnd.Value;

                double[] args = generator.Generate(rnd);

                random[i] = evaluator.EvaluateCompiled(args);
            });

            return(random);
        }
        private static double[] GenerateRandom(DistributionsEvaluator evaluator, Dictionary <string, DistributionSettings> randomSource, int samples)
        {
            double[] random = new double[samples];
            var      order  = evaluator.Parameters;

            int argsCount = order.Length;

            UnivariateContinuousDistribution[] orderedDistributions = new UnivariateContinuousDistribution[argsCount];

            ThreadLocal <double[]> argsLocal = new ThreadLocal <double[]>(() => new double[argsCount]);

            for (int i = 0; i < argsCount; i++)
            {
                string arg = order[i];

                if (randomSource.TryGetValue(arg, out DistributionSettings value))
                {
                    orderedDistributions[i] = value.GetUnivariateContinuoisDistribution();
                }
                else
                {
                    // TODO: check this out
                    // throw new DistributionsArgumentException($"Parameter value \"{arg}\" is missing", $"Отсутствует значение параметра \"{arg}\"");
                    throw new DistributionsArgumentException(DistributionsArgumentExceptionType.ParameterValueIsMissing, arg);
                }
            }

            Parallel.For(0, samples, i =>
            {
                double[] args = argsLocal.Value;
                Random rnd    = Rnd.Value;

                for (int j = 0; j < argsCount; j++)
                {
                    args[j] = orderedDistributions[j].Generate(rnd);
                }

                random[i] = evaluator.EvaluateCompiled(args);
            });

            return(random);
        }