Package flanagan.math

Examples of flanagan.math.ArrayMaths


        this.originalMedianSkewness = this.sod.medianSkewness();
        this.originalQuartileSkewness = this.sod.quartileSkewness();
        this.originalExcessKurtosis = this.sod.excessKurtosis();

        // Store original data sorted into ascending order
        ArrayMaths sorted = this.sod.sort();
        this.sortedOriginalData = sorted.array();
        this.originalIndices = sorted.originalIndices();

        // Standardize and store standardized data
        this.standardizedOriginalData = this.sod.standardize();

        // Calculate standardized original data statistics
        this.standardizedOriginalMinimum = this.sod.minimum();
        this.standardizedOriginalMaximum = this.sod.maximum();
        this.standardizedOriginalMedian = this.sod.median();
        this.standardizedOriginalRange = this.standardizedOriginalMaximum - this.standardizedOriginalMinimum;
        this.standardizedOriginalMean = 0.0;
        this.standardizedOriginalStandardDeviation = 1.0;
        this.standardizedOriginalVariance = 1.0;
        this.standardizedOriginalMomentSkewness = this.sod.momentSkewness();
        this.standardizedOriginalMedianSkewness = this.sod.medianSkewness();
        this.standardizedOriginalQuartileSkewness = this.sod.quartileSkewness();
        this.standardizedOriginalExcessKurtosis = this.sod.excessKurtosis();

        // Numbet of data points
        this.nData = this.originalData.length;

        //  Calculate uniform order statistic medians
        this.uniformOrderMedians = Stat.uniformOrderStatisticMedians(this.nData);

        // Calculate Gaussian N[0,1] order statistic medians
        this.gaussianOrderMedians = Stat.gaussianOrderStatisticMedians(this.nData);

        // calculate the correlation coefficient of the probability plot for the untransformed data
        Regression reg = new Regression(this.gaussianOrderMedians, ((new ArrayMaths(this.standardizedOriginalData)).sort().array()));
        reg.linear();
        this.originalSampleR = reg.getSampleR();
        double[] coeff = reg.getBestEstimates();
        this.originalIntercept = coeff[0];
        this.originalGradient = coeff[1];
View Full Code Here


        // initialize arrays and analyse original data
        if(!this.initializationDone)this.initialize();

        // Shift data to ensure all values are greater than zero
        this.lambdaTwo = 0.1*this.standardizedOriginalRange - this.standardizedOriginalMinimum;
        ArrayMaths st1 = this.sod.plus(this.lambdaTwo);
        this.shiftedStandardizedOriginalData = st1.getArray_as_double();

        // Create an instance of the BoxCoxFunction for Maximization
        BoxCoxFunction bcf = new BoxCoxFunction();
        bcf.shiftedData = this.shiftedStandardizedOriginalData;
        bcf.nData = this.nData;
        bcf.yTransform = new double[this.nData];
        bcf.gaussianOrderMedians = this.gaussianOrderMedians;

        // Create an instance of Maximization
        Maximization max = new Maximization();

        // Initial estimate of lambdaOne
        double[] start = {1.0};

        // Initial step size in maximization search
        double[] step = {0.3};

        // Tolerance for maximization search termination
        double maxzTol = 1e-9;

        // Maximiztaion of the Gaussian probabilty plot correlation coefficient varying lambdaOne
        max.nelderMead(bcf, start, step, maxzTol);

        // coeff[0] = value of lambdaOne for a maximum Gaussian probabilty plot correlation coefficient
        double[] coeff = max.getParamValues();
        double lambda1 = coeff[0];

        //maximum Gaussian probabilty plot correlation coefficient
        double sampleR1 = max.getMaximum();

        // Repeat maximization starting equidistant from the final value of lambdaOne on the opposite side from the starting estimate
        start[0] = lambda1 - (start[0] - lambda1);
        max.nelderMead(bcf, start, step, maxzTol);
        coeff = max.getParamValues();
        this.lambdaOne = coeff[0];
        this.transformedSampleR =  max.getMaximum();

        // Choose solution with the largest Gaussian probabilty plot correlation coefficient
        if(sampleR1>this.transformedSampleR){
            this.transformedSampleR = sampleR1;
            this.lambdaOne = lambda1;
        }

        // Store transformed data
        this.transformedData = new double[this.nData];
        if(this.lambdaOne==0.0){
            for(int i=0; i<this.nData; i++){
                this.transformedData[i] = Math.exp(this.shiftedStandardizedOriginalData[i]);
            }
        }
        else{
            for(int i=0; i<this.nData; i++){
                this.transformedData[i] = (Math.pow(this.shiftedStandardizedOriginalData[i], this.lambdaOne) - 1.0)/this.lambdaOne;
            }
        }

        // Standardize transformed data
        this.standardizedTransformedData =  (new Stat(this.transformedData)).standardize();

        // Calculate standardized transformed data statistics
        this.standardizedTransformedDataStatistics(this.standardizedTransformedData);

        // Obtain the intercept and gradient of the Gaussian probabilty plot
        ArrayMaths st4 = new ArrayMaths(this.standardizedTransformedData);
        st4 = st4.sort();
        double[] ordered = st4.array();
        Regression reg = new Regression(this.gaussianOrderMedians, ordered);
        reg.linear();
        coeff = reg.getBestEstimates();
        this.transformedIntercept = coeff[0];
        this.transformedGradient = coeff[1];
View Full Code Here

        // Calculate standardized transformed data statistics
        this.standardizedTransformedDataStatistics(this.standardizedTransformedData);

        // Obtain the intercept and gradient of the Gaussian probabilty plot
        ArrayMaths st4 = new ArrayMaths(this.standardizedTransformedData);
        st4 = st4.sort();
        double[] ordered = st4.array();
        Regression reg = new Regression(this.gaussianOrderMedians, ordered);
        reg.linear();
        double[] coeff = reg.getBestEstimates();
        this.transformedIntercept = coeff[0];
        this.transformedGradient = coeff[1];
View Full Code Here

    }

    // Return ordered transformed data
    public double[] orderedTransformedData(){
        if(!this.transformDone)this.transform();
        ArrayMaths am = new ArrayMaths(this.transformedData);
        double[] ordered = (am.sort()).array();
        return ordered;
    }
View Full Code Here

    public void transformedProbabilityPlot(){
        if(!this.transformDone)this.transform();

        double[][] data = PlotGraph.data(2,this.nData);
        data[0] = this.gaussianOrderMedians;
        data[1] = ((new ArrayMaths(this.standardizedTransformedData)).sort()).array();

        data[2] = this.gaussianOrderMedians;
        for(int i=0; i<this.nData; i++){
            data[3][i] = this.transformedIntercept + this.transformedGradient*this.gaussianOrderMedians[i];
        }
View Full Code Here

    public void originalProbabilityPlot(){
        if(!this.initializationDone)this.initialize();

        double[][] data = PlotGraph.data(2,this.nData);
        data[0] = this.gaussianOrderMedians;
        data[1] = ((new ArrayMaths(this.standardizedOriginalData)).sort()).array();
        data[2] = this.gaussianOrderMedians;
        for(int i=0; i<this.nData; i++){
            data[3][i] = this.originalIntercept + this.originalGradient*this.gaussianOrderMedians[i];
        }
        PlotGraph pg = new PlotGraph(data);
View Full Code Here

        else{
            for(int i=0; i<nData; i++)yTransform[i] = (Math.pow(shiftedData[i], x[0]) - 1.0)/x[0];
        }

        // Sort transformed array into ascending order
        am = new ArrayMaths(yTransform);
        am = am.sort();
        double[] yTrans = am.array();

        // Standardize
        st = new Stat(yTrans);
View Full Code Here

                          for(int i=0; i<nticks; i++)tickval[i] = ttickval[i];
                          break;
             }

            // ensure a zero value is truly zero and not a zero with rounding errors, e.g. 1e-17
             ArrayMaths am = new ArrayMaths(tickval);
            double max = am.maximum();
            double min = Math.abs(am.minimum());
            boolean testZero = true;
            int counter = 0;
            while(testZero){
                if(Math.abs(tickval[counter])<max*1e-4 || Math.abs(tickval[counter])<min*1e-4){
                    tickval[counter] = 0.0;
View Full Code Here

        super.nData0 = this.nAnalyteConcns;
        super.nXarrays = 1;
        super.nYarrays = 1;

        // Sort analyte concns into ascending order
        ArrayMaths am = new ArrayMaths(this.analyteConcns);
        am = am.sort();
        int[] indices = am.originalIndices();
        double[] hold = new double[this.nAnalyteConcns];
        hold = Conv.copy(this.analyteConcns);
        for(int i=0; i<this.nAnalyteConcns; i++)this.analyteConcns[i] = hold[indices[i]];
        hold = Conv.copy(this.responses);
        for(int i=0; i<this.nAnalyteConcns; i++)this.responses[i] = hold[indices[i]];
View Full Code Here

         // Construct matrix with a copy of an existing numberOfRows 1-D array of ArrayLists<Object>
        public Matrix(ArrayList<Object>[] twoDal){
            this.numberOfRows = twoDal.length;
            ArrayMaths[] twoD = new ArrayMaths[this.numberOfRows];
            for(int i=0; i<this.numberOfRows; i++){
                twoD[i] = new ArrayMaths(twoDal[i]);
            }

        this.numberOfColumns = twoD[0].length();
        this.matrix = new double[this.numberOfRows][this.numberOfColumns];
        for(int i=0; i<numberOfRows; i++){
View Full Code Here

TOP

Related Classes of flanagan.math.ArrayMaths

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.