/// <summary> /// Samples from the model. /// </summary> /// <param name="truth">The truth.</param> /// <param name="players">The players.</param> /// <param name="performanceVariance">The performance variance.</param> /// <param name="drawMargin">The draw margin.</param> /// <returns> /// The <see cref="Game" />. /// </returns> public static Game Sample(Marginals truth, IList <string> players, double performanceVariance, double drawMargin) { double perf1 = new Gaussian(truth.Skills[players[0]].GetMean(), performanceVariance).Sample(); double perf2 = new Gaussian(truth.Skills[players[1]].GetMean(), performanceVariance).Sample(); double diff = perf1 - perf2; MatchOutcome outcome = diff < drawMargin ? MatchOutcome.Draw : (diff > 0 ? MatchOutcome.Player1Win : MatchOutcome.Player2Win); return(TwoPlayerGame.CreateGame(Guid.NewGuid().ToString(), players[0], players[1], outcome)); }
/// <summary> /// Samples from the model. /// </summary> /// <param name="truth">The truth.</param> /// <param name="players">The players.</param> /// <param name="performanceVariance">The performance variance.</param> /// <returns>The <see cref="Game"/>.</returns> public static TwoPlayerGame Sample(Marginals truth, IList <string> players, double performanceVariance) { double perf1 = new Gaussian(truth.Skills[players[0]].GetMean(), performanceVariance).Sample(); double perf2 = new Gaussian(truth.Skills[players[1]].GetMean(), performanceVariance).Sample(); return(TwoPlayerGame.CreateGame( Guid.NewGuid().ToString(), players[0], players[1], perf1 > perf2 ? MatchOutcome.Player1Win : MatchOutcome.Player2Win)); }
/// <summary> /// Creates the toy inputs. /// </summary> /// <param name="matchOutcomes">The match outcomes.</param> /// <returns>The <see cref="Inputs{TwoPlayerGame}"/>.</returns> public static Inputs <TwoPlayerGame> CreateToyInputs(IEnumerable <MatchOutcome> matchOutcomes) { var inputs = new Inputs <TwoPlayerGame> { Mu = 120, Sigma = 40, Beta = 5, Gamma = 1.2, Games = new KeyedCollectionWithFunc <string, TwoPlayerGame>(ia => ia.Id), }; inputs.Games.AddRange(matchOutcomes.Select((ia, i) => TwoPlayerGame.CreateGame(i.ToString("N"), Jill, Fred, ia))); return(inputs); }