Пример #1
0
        // equality

        private static bool Equals(UncertainMeasurement <T> d1, UncertainMeasurement <T> d2)
        {
            if (Object.ReferenceEquals(d1, null))
            {
                if (Object.ReferenceEquals(d2, null))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (Object.ReferenceEquals(d2, null))
                {
                    return(false);
                }
                else
                {
                    return((d1.X.Equals(d2.X)) && (d1.Y == d2.Y));
                }
            }
        }
 /// <summary>
 /// Adds a new data point to the set.
 /// </summary>
 /// <param name="datum">The data point.</param>
 public void Add(UncertainMeasurement <T> datum)
 {
     if (datum == null)
     {
         throw new ArgumentNullException(nameof(datum));
     }
     data.Add(datum);
 }
Пример #3
0
        /// <summary>
        /// Determines whether the object represents the same data point.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns>True if the object represents the same data point, otherwise false.</returns>
        public override bool Equals(object obj)
        {
            UncertainMeasurement <T> d = obj as UncertainMeasurement <T>;

            if (Object.ReferenceEquals(d, null))
            {
                return(false);
            }
            else
            {
                return(Equals(this, d));
            }
        }
        public double Evaluate(double[] p)
        {
            double chi2 = 0.0;
            IEnumerator <UncertainMeasurement <T> > e = set.GetEnumerator();

            while (e.MoveNext())
            {
                UncertainMeasurement <T> point = e.Current;
                T      x  = point.X;
                double fx = f(p, x);
                double y  = point.Y.Value;
                double dy = point.Y.Uncertainty;
                double z  = (y - fx) / dy;
                chi2 += z * z;
            }
            return(chi2);
        }
 /// <summary>
 /// Determines whether the set contains the given data point.
 /// </summary>
 /// <param name="datum">The data point.</param>
 /// <returns>True if the set contains the given data point, otherwise false.</returns>
 public bool Contains(UncertainMeasurement <T> datum)
 {
     return(data.Contains(datum));
 }
 /// <summary>
 /// Removes a data point from the set.
 /// </summary>
 /// <param name="datum">The data point to remove.</param>
 /// <returns>True if the data point was found and removed; otherwise false.</returns>
 public bool Remove(UncertainMeasurement <T> datum)
 {
     return(data.Remove(datum));
 }