Ejemplo n.º 1
0
        public void UpdateCovarianceMatrixMDF(ILArray <double> vector)
        {
            // newCov = t-1/t * cov(t-1) + 1/t * (newVector - mean(t)) * (newVector - mean(t))T
            // oldPart = t-1/t * cov(t-1)
            // incrementalPart = 1/t * (newVector - mean(t)) * (newVector - mean(t))T
            // vector1 = (newVector - mean(t))
            // vector2 = (newVector - mean(t))T
            // newCovPart = vector1 * vector2

            //newVector - mean(t)
            //Vector v1 = new Vector(vector.ToArray());
            //v1.Subtract(this.meanMD);

            ILArray <double> vector1 = (vector - this.meanMDF).ToArray();
            ILArray <double> vector2 = vector1.ToArray();

            // transpone
            vector2 = vector2.T;

            double t = (double)this.items.Count;
            //double fragment1 = (t - 2) / (t - 1);
            //double fragment2 = t / (Math.Pow((t - 1), 2));

            double fragment1 = (t - 1 - this.GetAmnesicParameter(t)) / t;
            double fragment2 = (1 + this.GetAmnesicParameter(t)) / t;

            try
            {
                this.covarianceMatrixMDF = (this.covarianceMatrixMDF * fragment1) + (fragment2 * ILMath.multiply(vector1, vector2));
            }
            catch (Exception ee)
            {
                throw new InvalidCastException();
            }
        }
Ejemplo n.º 2
0
 public complex[] ILArray2Values(ILArray <complex> il, int width)
 {
     complex[] result = new complex[width];
     complex[] ila    = il.ToArray();
     for (int i = 0; i < width; i++)
     {
         result[i] = ila[i * width + i];
     }
     return(result);
 }
Ejemplo n.º 3
0
 public complex[,] ILArray2Array(ILArray <complex> il, int width)
 {
     complex[,] result = new complex[width, width];
     complex[] ila = il.ToArray();
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < width; j++)
         {
             result[i, j] = ila[i * width + j];
         }
     }
     return(result);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Update MDF mean with amnesic average
        /// </summary>
        /// <param name="vector">Vector, which should be add to mean</param>
        protected void UpdateMeanMDF(ILArray <double> vector)
        {
            double t = (double)this.items.Count;

            //double multiplier1 = (t - 1) / t;
            //double multiplier2 = 1 / t;
            double multiplier1 = (t - 1 - this.GetAmnesicParameter(t)) / t;
            double multiplier2 = (1 + this.GetAmnesicParameter(t)) / t;

            Vector incrementPart = new Vector(vector.ToArray());

            this.meanMDF = (this.meanMDF * multiplier1) + (vector * multiplier2);
        }
Ejemplo n.º 5
0
        private double[,] GetTwoDimensionalArray(ILArray <double> array, int dimensionX, int dimensionY)
        {
            double[,] result = new double[dimensionX, dimensionY];
            double[] source = array.ToArray();

            for (int i = 0; i < dimensionX; i++)
            {
                for (int j = 0; j < dimensionY; j++)
                {
                    result[i, j] = source[i * dimensionX + j];
                }
            }

            return(result);
        }
Ejemplo n.º 6
0
        public void UpdateCovarianceMatrixMDF_NonParametric(ILArray <double> vector)
        {
#warning this must be remake according to F. Amnesic average with parameters t1, t2

            // newCov = t-1/t * cov(t-1) + 1/t * (newVector - mean(t)) * (newVector - mean(t))T
            // oldPart = t-1/t * cov(t-1)
            // incrementalPart = 1/t * (newVector - mean(t)) * (newVector - mean(t))T
            // vector1 = (newVector - mean(t))
            // vector2 = (newVector - mean(t))T
            // newCovPart = vector1 * vector2

            //newVector - mean(t)
            //Vector v1 = new Vector(vector.ToArray());
            //v1.Subtract(this.meanMD);

            ILArray <double> vector1 = (vector - this.meanMDF).ToArray();
            ILArray <double> vector2 = vector1.ToArray();
            // transpone
            vector2 = vector2.T;

#warning need to edit update covariance matrix
            double t         = (double)this.items.Count;
            double fragment1 = (t - 2) / (t - 1);
            double fragment2 = t / (Math.Pow((t - 1), 2));

            //DenseMatrix oldPart = fragment1 * this.covarianceMatrix;
            //DenseMatrix newCovPart = vector1 * vector2;

            try
            {
                //DenseMatrix incrementalPart = newCovPart * fragment2;
                this.covarianceMatrixMDF = (this.covarianceMatrixMDF * fragment1) + (ILMath.multiply(vector1, vector2) * fragment2);
            }
            catch (Exception ee)
            {
                throw new InvalidCastException();
            }
        }
Ejemplo n.º 7
0
        private double[,] GetTwoDimensionalArray(ILArray<double> array, int dimensionX, int dimensionY)
        {
            double[,] result = new double[dimensionX, dimensionY];
            double[] source = array.ToArray();

            for (int i = 0; i < dimensionX; i++)
            {
                for (int j = 0; j < dimensionY; j++)
                {
                    result[i, j] = source[i * dimensionX + j];
                }
            }

            return result;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Update MDF mean with amnesic average
        /// </summary>
        /// <param name="vector">Vector, which should be add to mean</param>
        protected void UpdateMeanMDF(ILArray<double> vector)
        {
            double t = (double)this.items.Count;

            //double multiplier1 = (t - 1) / t;
            //double multiplier2 = 1 / t;
            double multiplier1 = (t - 1 - this.GetAmnesicParameter(t)) / t;
            double multiplier2 = (1 + this.GetAmnesicParameter(t)) / t;

            Vector incrementPart = new Vector(vector.ToArray());

            this.meanMDF = (this.meanMDF * multiplier1) + (vector * multiplier2);
        }