示例#1
0
        public override void Solve(Model model)
        {
            if (mInputs == null)
                GetNeededInputs();

            var e = new Expression(Formula, 
                            EvaluateOptions.IterateParameters | 
                            EvaluateOptions.IgnoreCase);

            foreach (var inputName in mInputs)
            {
                var objectDistribution = model[inputName].Output;
                e.Parameters[inputName] = objectDistribution;
            }

            var result = e.Evaluate() as List<object>;

            if (result == null)
                throw new Exception("");

            Output = new Distribution(GetDoubleArray(result));
        }
示例#2
0
 internal RandomDistributionIterator(Distribution target)
 {
     mTarget = target;
 }
示例#3
0
        public static Distribution InitConstant(double value, int size = DefaultSize)
        {
            var result = new Distribution(size);

            for (int i = 0; i < size; ++i) result[i] = value;

            return result;
        }
示例#4
0
        public static Distribution InitGaussian(double mean, double stdDev, int size = DefaultSize)
        {
            var result = new Distribution(size);

            for (int i = 0; i < result.Count; ++i)
            {
                result[i] = result.GetRandomGaussian() * stdDev + mean;
            }

            return result;
        }
示例#5
0
        public static Distribution Apply(Distribution d1, Distribution d2, Func<double, double, double> op)
        {
            var result = new Distribution(d1.Count);

            for (int i = 0; i < d1.Count; ++i)
            {
                result[i] = op(d1.GetRandomItem(), d2.GetRandomItem());
            }

            return result;
        }
示例#6
0
 internal RandomDistributionIterator(Distribution target)
 {
     mTarget = target;
 }