private void SetupInterpolatedPredictions( IPollsProvider polls, ElectionResult previousElectionResult) { InterpolatedPredictions.Clear(); if (!polls.PollsByDate.Any()) { return; } // Make up a set of dummy polls from the interpolated values DateTime startDate = polls.PollsByDate.First().PublicationDate; DateTime lastDate = polls.PollsByDate.Last().PublicationDate; int numberOfInterpolatedValues = (lastDate - startDate).Days + 1; List <PartyPollingResultsSet> constituencyPredictors = PartyPollingSets.Where(x => x.IsConstituency).ToList(); List <PartyPollingResultsSet> listPredictors = PartyPollingSets.Where(x => !x.IsConstituency).ToList(); for (int i = 0; i < numberOfInterpolatedValues; i++) { OpinionPoll interpolationPoll = GetInterpolationPoll(polls, startDate, i, constituencyPredictors, listPredictors); ElectionPrediction electionPrediction = new ElectionPrediction(previousElectionResult, interpolationPoll); InterpolatedPredictions.Add(new PollingPrediction(electionPrediction, interpolationPoll)); } }
public ElectionPrediction(ElectionPrediction src) { PreviousResult = src.PreviousResult; OpinionPoll = new OpinionPoll(src.OpinionPoll); PredictedResult = src.PredictedResult; PartyPredictions = new List <PartyVoteSwing>(); foreach (PartyVoteSwing partyPrediction in src.PartyPredictions) { PartyPredictions.Add(new PartyVoteSwing(partyPrediction)); } }
public void UpdatePredictions( IPollsProvider polls, ElectionResult previousElectionResult) { Predictions.Clear(); foreach (OpinionPoll poll in polls.PollsByDate) { ElectionPrediction electionPrediction = new ElectionPrediction(previousElectionResult, poll); Predictions.Add(electionPrediction); PollingPredictions.Add(new PollingPrediction(electionPrediction, poll)); } InitialisePartyPollingSets(polls); SetupInterpolatedPredictions(polls, previousElectionResult); OnPollsUpdated(null); }