Calculates the population standard deviation.
358227
def pstdev(data):
    """"""
    #: http://stackoverflow.com/a/27758326
    n = len(data)
    if n < 2:
        raise ValueError('variance requires at least two data points')
    ss = _ss(data)
    pvar = ss/n  # the population variance
    return pvar**0.5
763014
def Kdiag(self, X):
        """"""
        ret = np.empty(X.shape[0])
        ret[:] = self.variance
        return ret
1059434
public void stmSelection() {

    int[] idx = new int[populationSize];
    double[] nicheCount = new double[populationSize];

    int[][] solPref = new int[jointPopulation.size()][];
    double[][] solMatrix = new double[jointPopulation.size()][];
    double[][] distMatrix = new double[jointPopulation.size()][];
    double[][] fitnessMatrix = new double[jointPopulation.size()][];

    for (int i = 0; i < jointPopulation.size(); i++) {
      solPref[i] = new int[populationSize];
      solMatrix[i] = new double[populationSize];
      distMatrix[i] = new double[populationSize];
      fitnessMatrix[i] = new double[populationSize];
    }
    int[][] subpPref = new int[populationSize][];
    double[][] subpMatrix = new double[populationSize][];
    for (int i = 0; i < populationSize; i++) {
      subpPref[i] = new int[jointPopulation.size()];
      subpMatrix[i] = new double[jointPopulation.size()];
    }

    // Calculate the preference values of solution matrix
    for (int i = 0; i < jointPopulation.size(); i++) {
      int minIndex = 0;
      for (int j = 0; j < populationSize; j++) {
        fitnessMatrix[i][j] = fitnessFunction(jointPopulation.get(i), lambda[j]);
        distMatrix[i][j] = calculateDistance2(jointPopulation.get(i), lambda[j]);
        if (distMatrix[i][j] < distMatrix[i][minIndex]) {
          minIndex = j;
        }
      }
      nicheCount[minIndex] = nicheCount[minIndex] + 1;
    }

    // calculate the preference values of subproblem matrix and solution matrix
    for (int i = 0; i < jointPopulation.size(); i++) {
      for (int j = 0; j < populationSize; j++) {
        subpMatrix[j][i] = fitnessFunction(jointPopulation.get(i), lambda[j]);
        solMatrix[i][j] = distMatrix[i][j] + nicheCount[j];
      }
    }

    // sort the preference value matrix to get the preference rank matrix
    for (int i = 0; i < populationSize; i++) {
      for (int j = 0; j < jointPopulation.size(); j++) {
        subpPref[i][j] = j;
      }
      MOEADUtils.quickSort(subpMatrix[i], subpPref[i], 0, jointPopulation.size() - 1);
    }
    for (int i = 0; i < jointPopulation.size(); i++) {
      for (int j = 0; j < populationSize; j++) {
        solPref[i][j] = j;
      }
      MOEADUtils.quickSort(solMatrix[i], solPref[i], 0, populationSize - 1);
    }

    idx = stableMatching(subpPref, solPref, populationSize, jointPopulation.size());

    population.clear();
    for (int i = 0; i < populationSize; i++) {
      population.add(i, jointPopulation.get(idx[i]));
    }
  }
883858
def kurtosis(data):
    

    if not data:
        raise StatisticsError('kurtosis requires at least one data point')

    size = len(data)
    sd = stdev(data) ** 4

    if not sd:
        return 0.0

    mn = mean(data)
    return sum(map(lambda x: ((x - mn) ** 4 / sd), data)) / size - 3
32106
def dev(self):
    """"""
    if self.num == 0:
      return 0
    return math.sqrt(max(0, self.sum_sq / self.num - (self.sum / self.num)**2))
751971
@Override
    public double getStdDev() {
        // two-pass algorithm for variance, avoids numeric overflow

        if (values.length <= 1) {
            return 0;
        }

        final double mean = getMean();
        double variance = 0;

        for (int i = 0; i < values.length; i++) {
            final double diff = values[i] - mean;
            variance += normWeights[i] * diff*diff;
        }

        return Math.sqrt(variance);
    }
500672
def sde(self):
        
        variance = float(self.variance.values)
        lengthscale = float(self.lengthscale.values)
        foo  = np.sqrt(3.)/lengthscale
        F    = np.array([[0, 1], [-foo**2, -2*foo]])
        L    = np.array([[0], [1]])
        Qc   = np.array([[12.*np.sqrt(3) / lengthscale**3 * variance]])
        H    = np.array([[1, 0]])
        Pinf = np.array([[variance, 0],
        [0,              3.*variance/(lengthscale**2)]])
        # Allocate space for the derivatives
        dF    = np.empty([F.shape[0],F.shape[1],2])
        dQc   = np.empty([Qc.shape[0],Qc.shape[1],2])
        dPinf = np.empty([Pinf.shape[0],Pinf.shape[1],2])
        # The partial derivatives
        dFvariance       = np.zeros([2,2])
        dFlengthscale    = np.array([[0,0],
        [6./lengthscale**3,2*np.sqrt(3)/lengthscale**2]])
        dQcvariance      = np.array([12.*np.sqrt(3)/lengthscale**3])
        dQclengthscale   = np.array([-3*12*np.sqrt(3)/lengthscale**4*variance])
        dPinfvariance    = np.array([[1,0],[0,3./lengthscale**2]])
        dPinflengthscale = np.array([[0,0],
        [0,-6*variance/lengthscale**3]])
        # Combine the derivatives
        dF[:,:,0]    = dFvariance
        dF[:,:,1]    = dFlengthscale
        dQc[:,:,0]   = dQcvariance
        dQc[:,:,1]   = dQclengthscale
        dPinf[:,:,0] = dPinfvariance
        dPinf[:,:,1] = dPinflengthscale

        return (F, L, Qc, H, Pinf, dF, dQc, dPinf)
584354
def _ss(self, class_def):
        """"""
        yc = self.y[class_def]
        css = yc - yc.mean()
        css *= css
        return sum(css)
947404
private void computeMean() {
		meanError = 0;

		int size = allPoints.size();
		for (PointIndex<Point> inlier : allPoints) {
			Point pt = inlier.data;

			meanError += modelError.computeDistance(pt);
		}

		meanError /= size;

	}
486919
def std(self, bessel_correction=True):
        """"""
        if bessel_correction:
            n = self.n
            bc = n / (n - 1)
        else:
            bc = 1
        return np.sqrt(np.average((self.bin_centers - self.mean) ** 2, weights=self.histogram)) * bc
904182
public static double mean(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh) {
        double populationN = Descriptives.sum(populationNh.toFlatDataCollection());
        
        if(populationN<=0) {
            throw new IllegalArgumentException("The populationN parameter must be positive.");
        }
        
        double mean = 0.0;
        
        for(Map.Entry<Object, FlatDataCollection> entry : sampleDataCollection.entrySet()) {
            Object strata = entry.getKey();
            Integer strataPopulation = ((Number)populationNh.get(strata)).intValue();
        
            if(strataPopulation==null) {
                throw new IllegalArgumentException("Invalid strata population size.");
            }
            
            mean += strataPopulation*SimpleRandomSampling.mean(entry.getValue())/populationN;
        }
        
        return mean;
    }
25822
private static Stats calcStats(List<Double> nums) {
    double sum = 0.0, mean = 0.0, variance = 0.0, stdDev = 0.0;
    for (Double d : nums) {
      sum += d.doubleValue();
    }
    if (nums.size() > 0) {
      mean = sum / nums.size();
    }

    sum = 0.0;
    for (Double d : nums) {
      sum += (d.doubleValue() - mean) * (d.doubleValue() - mean);
    }
    if (nums.size() > 0) {
      variance = sum / nums.size();
    }

    stdDev = Math.sqrt(variance);
    return new Stats(mean, variance, stdDev);
  }
1224930
def get_deviations(self):
        

        mean_vec = self.mean()

        df = self.loc[:,:].copy()
        for col in df.columns:
            df.loc[:,col] -= mean_vec[col]
        return type(self).from_dataframe(pst=self.pst,df=df)
1129318
def std(self) -> Optional[float]:  #, ddof=0):
        
        # TODO: Add DOF
        if self._stats:
            return np.sqrt(self.variance())
        else:
            return None
1214683
def Mean(self):
        
        mu = 0.0
        for x, p in self.d.iteritems():
            mu += p * x
        return mu
1005720
def calc_pvalue(self, study_count, study_n, pop_count, pop_n):
        """"""
        # k, n = study_true, study_tot,
        # K, N = population_true, population_tot
        # def pvalue_population(int k, int n, int K, int N): ...
        return self.pval_fnc(study_count, study_n, pop_count, pop_n).two_tail
514676
def _calc_dic(self):
        """"""

        # Find mean deviance
        mean_deviance = np.mean(self.db.trace('deviance')(), axis=0)

        # Set values of all parameters to their mean
        for stochastic in self.stochastics:

            # Calculate mean of paramter
            try:
                mean_value = np.mean(
                    self.db.trace(
                        stochastic.__name__)(
                    ),
                    axis=0)

                # Set current value to mean
                stochastic.value = mean_value

            except KeyError:
                print_(
                    "No trace available for %s. DIC value may not be valid." %
                    stochastic.__name__)
            except TypeError:
                print_(
                    "Not able to calculate DIC: invalid stochastic %s" %
                    stochastic.__name__)
                return None

        # Return twice deviance minus deviance at means
        return 2 * mean_deviance - self.deviance