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)); }
internal RandomDistributionIterator(Distribution target) { mTarget = target; }
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; }
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; }
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; }