public bool Compute()
        {
            UnitsNet.Length[] sample = new UnitsNet.Length[NumberOfParameters];

            for (int j = 0; j < Iterations; j++)
            {
                for (int i = 0; i < sample.Length; i++)
                {
                    sample[i] = UnitsNet.Length.FromCentimeters(Random.NextDouble() * Range[i].Length.Centimeters + Range[i].Min.Centimeters);
                }

                UnitsNet.Length f = Function(sample);

                count++;
                sum  += f;
                sum2 += f * f;
            }

            double volume = 1;

            for (int i = 0; i < Range.Length; i++)
            {
                volume *= Range[i].Length.Centimeters;
            }

            double avg  = sum.Centimeters / count;
            double avg2 = sum2.SquareCentimeters / count;

            Area  = UnitsNet.Area.FromSquareCentimeters(volume * avg);
            Error = UnitsNet.Area.FromSquareCentimeters(volume * Math.Sqrt((avg2 - avg * avg) / count));

            return(true);
        }
 public void Reset()
 {
     this.sum   = UnitsNet.Length.FromCentimeters(0);
     this.sum2  = UnitsNet.Area.FromSquareCentimeters(0);
     this.count = 0;
     this.Area  = UnitsNet.Area.FromSquareCentimeters(0);
     this.Error = UnitsNet.Area.FromSquareCentimeters(Double.MaxValue);
 }
Exemplo n.º 3
0
        private void SensorUpdateTimerCallback(object state)
        {
            try
            {
                UnitsNet.Length distance = hcsr04.GetDistance();

                Debug.WriteLine($"{DateTime.UtcNow.ToShortTimeString()} Timer triggered " +
                                $"Distance: {distance.Meters:0.00}M " +
                                $" {distance.Centimeters:0.0}cm " +
                                $" {distance.Millimeters}mm");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemplo n.º 4
0
 public StatureForAge(int ageInYears, UnitsNet.Length stature)
 {
     Age     = PersonAge.FromYears(ageInYears);
     Stature = stature;
 }