Example #1
0
        private void init(double[,] matrix, double[][] array, string[] columnNames)
        {
            this.sourceMatrix = matrix;
            this.sourceArray  = array;
            this.columnNames  = columnNames;

            if (matrix != null)
            {
                this.samples   = matrix.GetLength(0);
                this.variables = matrix.GetLength(1);
            }
            else
            {
                this.samples   = array.Length;
                this.variables = array[0].Length;
            }



            // Create object-oriented structure to access data
            DescriptiveMeasures[] measures = new DescriptiveMeasures[variables];
            for (int i = 0; i < measures.Length; i++)
            {
                measures[i] = new DescriptiveMeasures(this, i);
            }
            this.measuresCollection = new DescriptiveMeasureCollection(measures);
        }
Example #2
0
        private void Compute(double[,] data, string[] columnNames)
        {
            if (columnNames == null)
            {
                // Generate column names as Column 1, Column 2, ...
                columnNames = new string[data.GetLength(1)];
                for (int i = 0; i < columnNames.Length; i++)
                {
                    columnNames[i] = "Column " + i;
                }
            }

            this.sourceMatrix = data;
            this.columnNames  = columnNames;

            this.samples   = data.GetLength(0);
            this.variables = data.GetLength(1);


            // Create object-oriented structure to access data
            DescriptiveMeasures[] measures = new DescriptiveMeasures[variables];
            for (int i = 0; i < measures.Length; i++)
            {
                measures[i] = new DescriptiveMeasures(this, i);
            }
            this.measuresCollection = new DescriptiveMeasureCollection(measures);
        }
Example #3
0
        /// <summary>
        ///   Constructs the Descriptive Analysis.
        /// </summary>
        ///
        /// <param name="data">The source data to perform analysis.</param>
        /// <param name="columnNames">Names for the analyzed variables.</param>
        ///
        public DescriptiveAnalysis(double[,] data, string[] columnNames)
        {
            // Initial argument checking
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            if (columnNames == null)
            {
                // Generate column names as Column 1, Column 2, ...
                columnNames = new string[data.GetLength(0)];
                for (int i = 0; i < columnNames.Length; i++)
                {
                    columnNames[i] = "Column " + i;
                }
            }

            this.sourceMatrix = data;
            this.columnNames  = columnNames;

            this.samples   = data.GetLength(0);
            this.variables = data.GetLength(1);


            // Create object-oriented structure to access data
            DescriptiveMeasures[] measures = new DescriptiveMeasures[variables];
            for (int i = 0; i < measures.Length; i++)
            {
                measures[i] = new DescriptiveMeasures(this, i);
            }
            this.measuresCollection = new DescriptiveMeasureCollection(measures);
        }
Example #4
0
        /// <summary>Constructs the Descriptive Analysis.</summary>
        /// <param name="data">The source data to perform analysis.</param>
        public DescriptiveAnalysis(double[,] data, string[] columnNames)
        {
            this.sourceMatrix = data;
            this.columnNames  = columnNames;

            this.samples   = data.GetLength(0);
            this.variables = data.GetLength(1);

            // Run analysis
            this.sums  = Statistics.Tools.Sum(data);
            this.means = Statistics.Tools.Mean(data, sums);
            this.standardDeviations = Statistics.Tools.StandardDeviation(data, means);
            this.ranges             = Statistics.Tools.Range(data);
            this.kurtosis           = Statistics.Tools.Kurtosis(data, means, standardDeviations);
            this.skewness           = Statistics.Tools.Skewness(data, means, standardDeviations);
            this.medians            = Statistics.Tools.Median(data);
            this.modes          = Statistics.Tools.Mode(data);
            this.variances      = Statistics.Tools.Variance(data, means);
            this.standardErrors = Statistics.Tools.StandardError(samples, standardDeviations);

            // Mean centered data
            this.dScores = (double[, ])data.Clone();
            Statistics.Tools.Center(dScores, means);

            // Mean centered and standardized data
            this.zScores = Statistics.Tools.ZScores(data, means, standardDeviations);

            // Covariance and correlation
            this.covarianceMatrix  = Statistics.Tools.Covariance(data, means);
            this.correlationMatrix = Statistics.Tools.Covariance(zScores);


            // Create object-oriented structure to access data
            DescriptiveMeasures[] measures = new DescriptiveMeasures[sourceMatrix.GetLength(1)];
            for (int i = 0; i < measures.Length; i++)
            {
                measures[i] = new DescriptiveMeasures(this, i);
            }
            this.measuresCollection = new DescriptiveMeasureCollection(measures);
        }