/// <summary>
        /// Add two Sufficient Statistics.
        /// </summary>
        /// <param name="stats1">Sufficient Statistics 1.</param>
        /// <param name="stats2">Sufficient Statistics 2.</param>
        /// <returns>Returns the Addition of all.</returns>
        public static StatisticsList Add(SufficientStatistics stats1, SufficientStatistics stats2)
        {
            StatisticsList newList = StatisticsList.GetInstance(stats1);

            newList.Add(stats2);
            return(newList);
        }
Exemple #2
0
        /// <summary>
        /// Compares Sufficient Statistics.
        /// </summary>
        /// <param name="stats">Sufficient Statistics.</param>
        /// <returns>Returns true if equal.</returns>
        public override bool Equals(SufficientStatistics stats)
        {
            if (stats == null)
            {
                return(false);
            }

            if (IsMissing() && stats.IsMissing())
            {
                return(true);
            }

            StatisticsList other = stats.AsStatisticsList();

            if (other._stats.Count != _stats.Count || GetHashCode() != other.GetHashCode())
            {
                return(false);
            }

            for (int i = 0; i < _stats.Count; i++)
            {
                if (!_stats[i].Equals(other._stats[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #3
0
 /// <summary>
 /// Try converting the given string into SufficientStatistics object.
 /// </summary>
 /// <param name="val">string to be converted.</param>
 /// <param name="result">SufficentStatistics object which corresponding to the given string.</param>
 /// <returns>Whether string was successfully converted.</returns>
 public static bool TryParse(string val, out SufficientStatistics result)
 {
     return
         (MissingStatistics.TryParse(val, out result) ||
          GaussianStatistics.TryParse(val, out result) ||
          BooleanStatistics.TryParse(val, out result) ||
          DiscreteStatistics.TryParse(val, out result) ||
          ContinuousStatistics.TryParse(val, out result) ||
          StatisticsList.TryParse(val, out result));
 }
        /// <summary>
        /// Add Sufficient Statistics.
        /// </summary>
        /// <param name="statsToAdd">Stats To Add.</param>
        public void Add(SufficientStatistics statsToAdd)
        {
            if (statsToAdd == null)
            {
                throw new ArgumentNullException("statsToAdd");
            }
            this.isMissing = (Count == 0 ? statsToAdd.IsMissing() : this.isMissing || statsToAdd.IsMissing());
            this.hashCode  = null;

            StatisticsList asList = statsToAdd as StatisticsList;

            if (asList != null)
            {
                this.stats.AddRange(asList.stats);
            }
            else
            {
                this.stats.Add(statsToAdd);
            }
        }
        /// <summary>
        /// Compares Sufficient Statistics.
        /// </summary>
        /// <param name="stats">Sufficient Statistics.</param>
        /// <returns>Returns true if equal.</returns>
        public override bool Equals(SufficientStatistics stats)
        {
            if (stats == null)
            {
                return(false);
            }

            if (IsMissing() && stats.IsMissing())
            {
                return(true);
            }

            StatisticsList other = stats.AsStatisticsList();

            if (other.stats.Count != this.stats.Count || GetHashCode() != other.GetHashCode())
            {
                return(false);
            }

            return(!this.stats.Where((t, i) => !t.Equals(other.stats[i])).Any());
        }
 /// <summary>
 /// Converts current object As Statistics List.
 /// </summary>
 /// <returns>Statistics List.</returns>
 public override StatisticsList AsStatisticsList()
 {
     return(IsMissing() ? StatisticsList.GetMissingInstance : StatisticsList.GetInstance(this));
 }
        /// <summary>
        /// Gives the clone of Statistics List.
        /// </summary>
        /// <returns>Returns clone of Statistics List.</returns>
        public object Clone()
        {
            StatisticsList result = new StatisticsList(this.stats);

            return(result);
        }