public static void RunCyclingTime3() { ModelDataMixed initPriors; double[] trainingData = new double[] { 13, 17, 16, 12, 13, 12, 14, 18, 16, 16, 27, 32 }; initPriors.AverageTimeDist = new Gaussian[] { new Gaussian(15.0, 100), new Gaussian(30.0, 100) }; initPriors.TrafficNoiseDist = new Gamma[] { new Gamma(2.0, 0.5), new Gamma(2.0, 0.5) }; initPriors.MixingDist = new Dirichlet(1, 1); CyclistMixedTraining cyclistMixedTraining = new CyclistMixedTraining(); cyclistMixedTraining.CreateModel(); cyclistMixedTraining.SetModelData(initPriors); ModelDataMixed posteriors = cyclistMixedTraining.InferModelData(trainingData); Console.WriteLine("Average time distribution 1 = " + posteriors.AverageTimeDist[0]); Console.WriteLine("Average time distribution 2 = " + posteriors.AverageTimeDist[1]); Console.WriteLine("Noise distribution 1 = " + posteriors.TrafficNoiseDist[0]); Console.WriteLine("Noise distribution 2 = " + posteriors.TrafficNoiseDist[1]); Console.WriteLine("Mixing coefficient distribution = " + posteriors.MixingDist); CyclistMixedPrediction cyclistMixedPrediction = new CyclistMixedPrediction(); cyclistMixedPrediction.CreateModel(); cyclistMixedPrediction.SetModelData(posteriors); Gaussian tomorrowsTime = cyclistMixedPrediction.InferTomorrowsTime(); double tomorrowsMean = tomorrowsTime.GetMean(); double tomorrowsStdDev = Math.Sqrt(tomorrowsTime.GetVariance()); Console.WriteLine("Tomorrows expected time: {0:f2}", tomorrowsMean); Console.WriteLine("Tomorrows standard deviation: {0:f2}", tomorrowsStdDev); }
static void Main(string[] args) { ModelDataMixed initpriors; double[] trainingData = new double[] { 13, 17, 16, 12, 13, 12, 14, 18, 16, 16, 27, 32 }; initpriors.averageTimeDist = new Gaussian[] { new Gaussian(15.0, 100.0), new Gaussian(30.0, 100.00) }; initpriors.trafficNoiseDist = new Gamma[] { new Gamma(2.0, 0.5), new Gamma(2.0, 0.5) }; initpriors.mixingDist = new Dirichlet(1, 1); CyclingMixedTraining cyclingMixedTraining = new CyclingMixedTraining(); cyclingMixedTraining.CreateModel(); cyclingMixedTraining.SetModelData(initpriors); ModelDataMixed posteriors = cyclingMixedTraining.InferModelData(trainingData); CyclistMixedPrediction cyclistMixedPrediction = new CyclistMixedPrediction(); cyclistMixedPrediction.CreateModel(); cyclistMixedPrediction.SetModelData(posteriors); Gaussian tomorrowsTime = cyclistMixedPrediction.InferTomorrowsTime(); Console.WriteLine("Tomorrow's predicted time is {0:f2}", tomorrowsTime.GetMean()); Console.WriteLine("Tomorrow's predicted standard deviation is {0:f2}", Math.Sqrt(tomorrowsTime.GetVariance())); Console.ReadKey(); }
public void SetModelData(ModelDataMixed modelData) { averageTimePriors.ObservedValue = modelData.averageTimeDist; trafficNoisePriors.ObservedValue = modelData.trafficNoiseDist; mixingPrior.ObservedValue = modelData.mixingDist; }