Example #1
0
 public void WeightedMeanTest()
 {
     var s = new Descriptives();
     s.AddSample(1,2);
     Assert.AreEqual(s.Mean(), 1);
     s.AddSample(2);
     Assert.IsTrue(System.Math.Abs(s.Mean() - (4.0/3)) < 1e-12);
     s.AddSample(3, 2);
     Assert.IsTrue(System.Math.Abs(s.Mean() - 2) < 1e-12);
 }
Example #2
0
 public void MeanTest()
 {
     var s = new Descriptives();
     Assert.IsTrue(Double.IsNaN(s.Mean()));
     s.AddSample(1);
     Assert.AreEqual(s.Mean(), 1);
     s.AddSample(2);
     Assert.IsTrue(System.Math.Abs(s.Mean() - 1.5) < 1e-12);
     s.AddSample(3);
     Assert.IsTrue(System.Math.Abs(s.Mean() - 2) < 1e-12);
 }
Example #3
0
 private void ReportStats(Descriptives s)
 {
     lock (s)
     {
         AverageField.Text = s.Mean().ToString();
         StdDevField.Text = s.StdDev().ToString();
     }
 }
Example #4
0
        /// <summary>
        /// simulate one ant farm, return true (continue) unless max cube count has been reached
        /// </summary>
        private bool Run1()
        {
            var s = new Descriptives(); // departure time statistics for this cube
            var cube = new Cube(m_nAnts, this);
            for (int t = 0; t < m_nMaxTime; ++t)
            {
                int escaped = cube.Step();
                s.AddSample(t + 1, escaped); // if escaped on step 0, it's at time 1.
                if (cube.Empty)
                    break;
            }

            double completed;
            lock (m_summarystats)
            {
                completed = m_summarystats.Mass();
                if (completed < m_nCubes)
                    m_summarystats.AddSample(s.Mean());
            }

            if (completed+1 == m_nCubes && m_OnCompletion != null)
                m_OnCompletion(m_summarystats);

            return completed+1 < m_nCubes;
        }