Java mean std(double[] a, int size, double mean)

Here you can find the source of std(double[] a, int size, double mean)

Description

std

License

Apache License

Declaration

public final static double std(double[] a, int size, double mean) 

Method Source Code

//package com.java2s;
/* //from   w w w.  j a v  a  2  s  .c o  m
 * MHAP package
 * 
 * This  software is distributed "as is", without any warranty, including 
 * any implied warranty of merchantability or fitness for a particular
 * use. The authors assume no responsibility for, and shall not be liable
 * for, any special, indirect, or consequential damages, or any damages
 * whatsoever, arising out of or in connection with the use of this
 * software.
 * 
 * Copyright (c) 2014 by Konstantin Berlin and Sergey Koren
 * University Of Maryland
 * 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

public class Main {
    public final static double std(double[] a, int size, double mean) {
        double x = 0.0;
        for (int iter = 0; iter < size; iter++) {
            double val = a[iter] - mean;
            x += val * val;
        }

        return Math.sqrt(x / (double) (size - 1));
    }

    public final static double std(int[] a, int size, double mean) {
        double x = 0.0;
        for (int iter = 0; iter < size; iter++) {
            double val = (double) a[iter] - mean;
            x += val * val;
        }

        return Math.sqrt(x / (double) (size - 1));
    }
}

Related

  1. meanSquaredError(double[] x, double[] y)
  2. meanSquaredError(double[][] vectorBatch1, double[][] vectorBatch2)
  3. meanWithoutZeros(int[] in, int x1, int x2)
  4. meanWithoutZerosCentered(int[] in, int center, int width)
  5. std(double[] a, double mean, boolean isUnbiasedEstimator)
  6. std(double[] array, double mean)
  7. stdDeviation(int[] values, double mean)
  8. stdDevsOfRows(double[][] matrix, double[] means)
  9. stdev(final double[] values, final double mean)