public void CopyTo(StatisticalQuantity dest)
        {
            //checks for null entries
            if (dest == null)
            {
                return;
            }

            //sets capacity
            dest.MaxNumSamples = this.MaxNumSamples;

            //copies samples
            this.Samples?.CopyTo(dest.Samples, 0);

            //copies all other statistical fields
            dest.Range = this.Range;
            //dest.QuantityCount = this.QuantityCount;
            dest.ValueCount       = this.ValueCount;
            dest._lastValue       = this._lastValue;
            dest._sampleStatistic = this._sampleStatistic;
            dest._stepSampleCount = this._stepSampleCount;
            dest.Max         = this.Max;
            dest.Min         = this.Min;
            dest.SampleCount = this.SampleCount;
            dest.Id          = this.Id;
        }
        public StatisticalQuantity Clone()
        {
            var quantity = new StatisticalQuantity(this.MaxNumSamples);

            this.CopyTo(quantity);
            return(quantity);
        }
 public static void Copy(StatisticalQuantity source, StatisticalQuantity dest)
 {
     //checks for null entries
     if ((source == null) || (dest == null))
     {
         return;
     }
     source.CopyTo(dest);
 }
        public void AverageWith(StatisticalQuantity quantity)
        {
            //updates stats based on other quantity's stats
            this._sampleStatistic.Add(quantity._sampleStatistic);
            this.Max = System.Math.Max(this.Max, quantity.Max);
            this.Min = System.Math.Min(this.Min, quantity.Min);

            //determines min sample count from quantities values
            var numSamples = System.Math.Min(this.SampleCount, quantity.SampleCount);

            //updates each sample
            for (var i = 0; i < numSamples; i++)
            {
                this.Samples[i].Add(quantity.Samples[i]);
            }

            //average (last) value
            if (numSamples > 0)
            {
                this._lastValue = this.Samples[numSamples - 1].Mean;
            }
        }