Example #1
0
 /// <summary>
 /// Instantiates a normalizer
 /// </summary>
 /// <param name="reserveRatio">
 /// Reserve held by a normalizer to cover cases where future data exceeds a known range of sample data.
 /// </param>
 /// <param name="standardize">
 /// Specifies whether to apply data standardization
 /// </param>
 public Normalizer(double reserveRatio, bool standardize = true)
 {
     _standardization = standardize;
     _normRange       = new Interval(DefaultNormRangeMin, DefaultNormRangeMax);
     _samplesStat     = new BasicStat();
     _reserveRatio    = reserveRatio;
     return;
 }
Example #2
0
 /// <summary>
 /// Constructs normalizer
 /// </summary>
 /// <param name="normRange">
 /// Range of normalized values
 /// </param>
 /// <param name="reserveRatio">
 /// Reserve held by a normalizer to cover cases where future data exceeds a known range of sample data.
 /// </param>
 /// <param name="standardize">
 /// Specifies whether to apply data standardization
 /// </param>
 public Normalizer(Interval normRange, double reserveRatio, bool standardize = true)
 {
     _standardization = standardize;
     _normRange       = new Interval(normRange);
     _samplesStat     = new BasicStat();
     _reserveRatio    = reserveRatio;
     return;
 }
Example #3
0
 /// <summary>
 /// Constructs normalizer
 /// </summary>
 /// <param name="normRange">
 /// Range of normalized values
 /// </param>
 /// <param name="reserveRatio">
 /// Reserve held by a normalizer to cover cases where future data exceeds a known range of sample data.
 /// </param>
 /// <param name="standardize">
 /// Specifies whether to apply data standardization
 /// </param>
 /// <param name="threadSafe">Specifies if to create thread safe instance</param>
 public Normalizer(Interval normRange, double reserveRatio, bool standardize = true, bool threadSafe = false)
 {
     Standardization = standardize;
     NormRange       = new Interval(normRange, threadSafe);
     SamplesStat     = new BasicStat(threadSafe);
     ReserveRatio    = reserveRatio;
     return;
 }
Example #4
0
 //Constructors
 /// <summary>
 /// A deep copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 public Normalizer(Normalizer source)
 {
     _standardization = source._standardization;
     _reserveRatio    = source._reserveRatio;
     _samplesStat     = new BasicStat(source._samplesStat);
     _normRange       = new Interval(source._normRange);
     return;
 }
Example #5
0
 //Constructors
 /// <summary>
 /// A deep copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 /// <param name="threadSafe">Specifies if to create thread safe instance</param>
 public Normalizer(Normalizer source, bool threadSafe = false)
 {
     Standardization = source.Standardization;
     ReserveRatio    = source.ReserveRatio;
     SamplesStat     = new BasicStat(source.SamplesStat, threadSafe);
     NormRange       = new Interval(source.NormRange, threadSafe);
     return;
 }
Example #6
0
 /// <summary>
 /// Adopts data from the source normalizer
 /// </summary>
 public void Adopt(Normalizer source)
 {
     Standardization = source.Standardization;
     ReserveRatio    = source.ReserveRatio;
     SamplesStat     = new BasicStat(source.SamplesStat);
     NormRange       = new Interval(source.NormRange);
     return;
 }
Example #7
0
 //Constructors
 /// <summary>
 /// Creates an uninitialized instance.
 /// </summary>
 /// <param name="binBorder">The binary border. A value less than this border is considered as the 0. The 1 otherwise.</param>
 public BinErrStat(double binBorder)
 {
     BinBorder        = binBorder;
     BinValErrStat    = new BasicStat[2];
     BinValErrStat[0] = new BasicStat();
     BinValErrStat[1] = new BasicStat();
     TotalErrStat     = new BasicStat();
     return;
 }
Example #8
0
 /// <summary>
 /// The deep copy constructor.
 /// </summary>
 /// <param name="source">The source instance.</param>
 public BinErrStat(BinErrStat source)
 {
     BinBorder        = source.BinBorder;
     BinValErrStat    = new BasicStat[2];
     BinValErrStat[0] = new BasicStat(source.BinValErrStat[0]);
     BinValErrStat[1] = new BasicStat(source.BinValErrStat[1]);
     TotalErrStat     = new BasicStat(source.TotalErrStat);
     return;
 }
Example #9
0
 //Constructors
 /// <summary>
 /// Creates an uninitialized instance
 /// </summary>
 /// <param name="refBinValDistr">Reference distribution of 0/1 values</param>
 public BinErrStat(BinDistribution refBinValDistr)
 {
     RefBinValDistr   = refBinValDistr.DeepClone();
     ThisBinValDistr  = new BinDistribution(RefBinValDistr.BinBorder);
     BinValErrStat    = new BasicStat[2];
     BinValErrStat[0] = new BasicStat();
     BinValErrStat[1] = new BasicStat();
     TotalErrStat     = new BasicStat();
     return;
 }
Example #10
0
 /// <summary>
 /// Deep copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 public BinErrStat(BinErrStat source)
 {
     RefBinValDistr   = source.RefBinValDistr.DeepClone();
     ThisBinValDistr  = source.ThisBinValDistr.DeepClone();
     BinValErrStat    = new BasicStat[2];
     BinValErrStat[0] = new BasicStat(source.BinValErrStat[0]);
     BinValErrStat[1] = new BasicStat(source.BinValErrStat[1]);
     TotalErrStat     = new BasicStat(source.TotalErrStat);
     return;
 }
Example #11
0
        /// <summary>
        /// Returns statistics of data samples currently stored in the internal sliding window
        /// </summary>
        /// <param name="latestFirst">Specifies logical order (latest..oldest or oldest..latest)</param>
        /// <param name="reqNumOfSamples">Number of requiered samples</param>
        public BasicStat GetDataStat(bool latestFirst = false, int reqNumOfSamples = -1)
        {
            int       numOfSamplesToBeProcessed = reqNumOfSamples == -1 ? _dataWindow.Count : reqNumOfSamples;
            BasicStat stat = new BasicStat();

            for (int i = 0; i < numOfSamplesToBeProcessed; i++)
            {
                stat.AddSampleValue(_dataWindow.GetElementAt(i, latestFirst));
            }
            return(stat);
        }
Example #12
0
        /// <summary>
        /// Computes the statistics of the differences of the data in the window.
        /// </summary>
        /// <param name="reqNumOfSamples">The requiered mumber of samples (-1 means all).</param>
        public BasicStat GetDataDiffStat(int reqNumOfSamples = -1)
        {
            int numOfSamplesToBeProcessed = reqNumOfSamples == -1 ? _dataQueue.Count : reqNumOfSamples;

            CheckReadyness(numOfSamplesToBeProcessed);
            BasicStat stat = new BasicStat();

            for (int i = numOfSamplesToBeProcessed - 2; i >= 0; i--)
            {
                stat.AddSample(_dataQueue.GetElementAt(i, true) - _dataQueue.GetElementAt(i + 1, true));
            }
            return(stat);
        }
Example #13
0
 /// <summary>
 /// Copies all internal attribute values from the source instance into this instance
 /// </summary>
 /// <param name="source">The source instance</param>
 public void CopyFrom(BasicStat source)
 {
     if (_threadSafe)
     {
         lock (source._lock)
         {
             CopyFromInternal(source);
         }
     }
     else
     {
         CopyFromInternal(source);
     }
     return;
 }
Example #14
0
        /// <summary>
        /// Computes error statistics of Y values (computedY - sampleY)
        /// </summary>
        public BasicStat ComputeRegressionErrStat()
        {
            ComputeRegression();
            BasicStat errStat = new BasicStat();

            if (_pointCollection.Count > 0)
            {
                foreach (Point2D point in _pointCollection)
                {
                    double regrY = _a * point._x + _b;
                    errStat.AddSampleValue(Math.Abs(regrY - point._y));
                }
            }
            return(errStat);
        }
Example #15
0
 private void CopyFromInternal(BasicStat source)
 {
     _sum                 = source._sum;
     _sumOfSquares        = source._sumOfSquares;
     _min                 = source._min;
     _max                 = source._max;
     _numOfSamples        = source._numOfSamples;
     _numOfNonzeroSamples = source._numOfNonzeroSamples;
     _recompute           = source._recompute;
     _arithAvg            = source._arithAvg;
     _rootMeanSquare      = source._rootMeanSquare;
     _variance            = source._variance;
     _stdDev              = source._stdDev;
     _spanDev             = source._spanDev;
     return;
 }
Example #16
0
 /// <summary>
 /// Copies all internal attribute values from the source instance into this instance
 /// </summary>
 /// <param name="source">The source instance</param>
 public void CopyFrom(BasicStat source)
 {
     lock (_lock)
     {
         _sum                 = source._sum;
         _sumOfSquares        = source._sumOfSquares;
         _min                 = source._min;
         _max                 = source._max;
         _numOfSamples        = source._numOfSamples;
         _numOfNonzeroSamples = source._numOfNonzeroSamples;
         _recompute           = source._recompute;
         _arithAvg            = source._arithAvg;
         _rootMeanSquare      = source._rootMeanSquare;
         _variance            = source._variance;
         _stdDev              = source._stdDev;
         _spanDev             = source._spanDev;
     }
     return;
 }
Example #17
0
 /// <summary>
 /// The copy constructor
 /// </summary>
 /// <param name="source">Source instance</param>
 /// <param name="threadSafe">Specifies whether to create thread safe instance</param>
 public BasicStat(BasicStat source, bool threadSafe = false)
     : this(threadSafe)
 {
     CopyFrom(source);
     return;
 }
Example #18
0
 /// <summary>
 /// The copy constructor
 /// </summary>
 public BasicStat(BasicStat source)
 {
     CopyFrom(source);
     return;
 }