private static void DoTestAverageAndStdDev(RunningAverageAndStdDev average) { Assert.AreEqual(0, average.Count); Assert.IsTrue(Double.IsNaN(average.Average)); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); average.AddDatum(6.0); Assert.AreEqual(1, average.Count); Assert.AreEqual(6.0, average.Average, EPSILON); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); average.AddDatum(6.0); Assert.AreEqual(2, average.Count); Assert.AreEqual(6.0, average.Average, EPSILON); Assert.AreEqual(0.0, average.StandardDeviation, EPSILON); average.RemoveDatum(6.0); Assert.AreEqual(1, average.Count); Assert.AreEqual(6.0, average.Average, EPSILON); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); average.AddDatum(-4.0); Assert.AreEqual(2, average.Count); Assert.AreEqual(1.0, average.Average, EPSILON); Assert.AreEqual(5.0 * 1.4142135623730951, average.StandardDeviation, EPSILON); average.RemoveDatum(4.0); Assert.AreEqual(1, average.Count); Assert.AreEqual(-2.0, average.Average, EPSILON); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); }
public StatsCallable(Action deleg, bool logStats, RunningAverageAndStdDev timing, AtomicInteger noEstimateCounter) { this._Delegate = deleg; this.logStats = logStats; this.timing = timing; this.noEstimateCounter = noEstimateCounter; }
private static void DoTestAverageAndStdDev(RunningAverageAndStdDev average) { Assert.AreEqual(0, average.Count); Assert.IsTrue(Double.IsNaN(average.Average)); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); average.AddDatum(6.0); Assert.AreEqual(1, average.Count); Assert.AreEqual(6.0, average.Average, EPSILON); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); average.AddDatum(6.0); Assert.AreEqual(2, average.Count); Assert.AreEqual(6.0, average.Average, EPSILON); Assert.AreEqual(0.0, average.StandardDeviation, EPSILON); average.RemoveDatum(6.0); Assert.AreEqual(1, average.Count); Assert.AreEqual(6.0, average.Average, EPSILON); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); average.AddDatum(-4.0); Assert.AreEqual(2, average.Count); Assert.AreEqual(1.0, average.Average, EPSILON); Assert.AreEqual(5.0 * 1.4142135623730951, average.StandardDeviation, EPSILON); average.RemoveDatum(4.0); Assert.AreEqual(1, average.Count); Assert.AreEqual(-2.0, average.Average, EPSILON); Assert.IsTrue(Double.IsNaN(average.StandardDeviation)); }
public double GetTransformedValue(Preference pref) { RunningAverageAndStdDev meanAndStdev = meanAndStdevs.Get(pref.User); if (meanAndStdev.Count > 1) { double stdev = meanAndStdev.StandardDeviation; if (stdev > 0.0) { return((pref.Value - meanAndStdev.Average) / stdev); } } return(0.0); }
public static void execute(List <Action> callables, AtomicInteger noEstimateCounter, RunningAverageAndStdDev timing) { List <Action> list = wrapWithStatsCallables(callables, noEstimateCounter, timing); int processorCount = Environment.ProcessorCount; Task[] tasks = new Task[list.Count]; log.info("Starting timing of {} tasks in {} threads", new object[] { list.Count, processorCount }); try { for (int i = 0; i < tasks.Length; i++) { tasks[i] = Task.Factory.StartNew(list[i]); } Task.WaitAll(tasks, 0x2710); } catch (Exception exception) { throw new TasteException(exception.Message, exception); } }
private static List <Action> wrapWithStatsCallables(List <Action> callables, AtomicInteger noEstimateCounter, RunningAverageAndStdDev timing) { List <Action> list = new List <Action>(); for (int i = 0; i < callables.Count; i++) { bool logStats = (i % 0x3e8) == 0; list.Add(new Action(new StatsCallable(callables[i], logStats, timing, noEstimateCounter).call)); } return(list); }
public InvertedRunningAverageAndStdDev(RunningAverageAndStdDev delegate_) { this._holder = delegate_; }
public InvertedRunningAverageAndStdDev(RunningAverageAndStdDev deleg) { this._Delegate = deleg; }
public InvertedRunningAverageAndStdDev(RunningAverageAndStdDev delegate_) { this._holder = delegate_; }