public void Estimate_ParametersPassed_PiCalculatedAndReturned() { const int numberOfStates = 2; var util = new TestDataUtils(); var observations = util.GetSvcData(util.FTSEFilePath, new DateTime(2010, 12, 18), new DateTime(2011, 12, 18)); var model = HiddenMarkovModelStateFactory.GetState(new ModelCreationParameters <NormalDistribution>() { NumberOfStates = numberOfStates, Emissions = CreateEmissions(observations, numberOfStates) }); model.Normalized = true; var observationsList = new List <IObservation>(); for (var i = 0; i < observations.Length; i++) { observationsList.Add(new Observation(observations[i], i.ToString())); } var baseParameters = new BasicEstimationParameters <NormalDistribution> { Model = model, Observations = Helper.Convert(observations), Normalized = model.Normalized }; var alphaEstimator = new AlphaEstimator <NormalDistribution>(); var alpha = alphaEstimator.Estimate(baseParameters); var betaEstimator = new BetaEstimator <NormalDistribution>(); var beta = betaEstimator.Estimate(baseParameters); var @params = new AdvancedEstimationParameters <NormalDistribution> { Alpha = alpha, Beta = beta, Observations = observationsList, Model = model, Normalized = model.Normalized }; var gammaEstimator = new GammaEstimator <NormalDistribution>(); var estimator = new PiEstimator(); var parameters = new PiParameters { Gamma = gammaEstimator.Estimate(@params), N = model.N, Normalized = model.Normalized }; var estimatedPi = estimator.Estimate(parameters); Assert.AreEqual(1d, Math.Round(estimatedPi[0] + estimatedPi[1], 5)); }
public void PiEstimator_ParameterPassed_PiEstimatorCreated() { var estimator = new PiEstimator(); Assert.IsNotNull(estimator); }