/* Generate individual parameter values based on the new mean (newMean).
970368
public void generateValues(double newMean) {
        double meanWithOffset = newMean + offset;
        for (int i = 0; i < data.length; i++) {
            data[i] = meanWithOffset * proportional_dev[i] - offset;
        }
        mean = newMean;
    }
325172
def generate(self):
        '''
        
        '''
        observed_arr = None
        for row in range(self.__batch_size):
            arr = None
            for d in range(self.__dim):
                _arr = self.__generate_sin(
                    amp=self.__amp,
                    sampling_freq=self.__sampling_freq,
                    freq=self.__freq,
                    sec=self.__sec,
                    seq_len=self.__seq_len
                )
                _arr = np.expand_dims(_arr, axis=0)
                if arr is None:
                    arr = _arr
                else:
                    arr = np.r_[arr, _arr]

            arr = np.expand_dims(arr, axis=0)

            if observed_arr is None:
                observed_arr = arr
            else:
                observed_arr = np.r_[observed_arr, arr]

        observed_arr = observed_arr.transpose((0, 2, 1))
        gauss_noise = np.random.normal(loc=self.__mu, scale=self.__sigma, size=observed_arr.shape)
        observed_arr = observed_arr + gauss_noise
        if self.noise_sampler is not None:
            self.noise_sampler.output_shape = observed_arr.shape
            observed_arr += self.noise_sampler.generate()

        if self.__norm_mode == "z_score":
            if observed_arr.std() != 0:
                observed_arr = (observed_arr - observed_arr.mean()) / observed_arr.std()
        elif self.__norm_mode == "min_max":
            if (observed_arr.max() - observed_arr.min()) != 0:
                observed_arr = (observed_arr - observed_arr.min()) / (observed_arr.max() - observed_arr.min())
        elif self.__norm_mode == "tanh":
            observed_arr = np.tanh(observed_arr)

        return observed_arr
553981
def sma(arg, n):
    
    if n == 0:
        return pd.expanding_mean(arg)
    else:
        return pd.rolling_mean(arg, n, min_periods=n)
752706
def generateImplicitParameters(obj):
        
        if not hasattr(obj, 'uid'):
            rand = int(random.random() * 100000)
            now = datetime.datetime.now(utc)
            now = dateTimeToString(now)
            host = socket.gethostname()
            obj.add(ContentLine('UID', [], "{0} - {1}@{2}".format(now, rand,
                                                                  host)))
910623
def PARAMLIMITS(self, value):
        """"""
        assert set(value.keys()) == set(self.PARAMLIMITS.keys()), "The \
                new parameter limits are not defined for the same set \
                of parameters as before."
        for param in value.keys():
            assert value[param][0] < value[param][1], "The new \
                    minimum value for {0}, {1}, is equal to or \
                    larger than the new maximum value, {2}"\
                    .format(param, value[param][0], value[param][1])
        self._PARAMLIMITS = value.copy()
335541
def mean
      mean = Pair.new(0, 0)
      weight = 0

      objects.each do |object, n|
        (1..n).each do |_i|
          mean + object
          weight += 1
        end
      end
      mean / weight
      mean
    end
1212377
public static Mean[] newArray(int dimensionality) {
    Mean[] arr = new Mean[dimensionality];
    for(int i = 0; i < dimensionality; i++) {
      arr[i] = new Mean();
    }
    return arr;
  }
876930
public static double mean(Collection<? extends Number> values) {
        double sum = 0d;
        for (Number n : values)
            sum += n.doubleValue();
        return sum / values.size();
    }
1245739
def params_of_mean(value=array([-.005, 1.]), tau=.1, rate=4.):
    

    def logp(value, tau, rate):
        if value[1] > 0 and value[1] + value[0] * 110 > 0:
            return normal_like(value[0], 0., tau) + \
                exponential_like(value[1], rate)
        else:
            return -Inf

    def random(tau, rate):
        val = zeros(2)
        val[0] = rnormal(0., tau)
        val[1] = rexponential(rate)
        while val[1] < 0 or val[1] + val[0] * 110 <= 0:
            val[0] = rnormal(0., tau)
            val[1] = rexponential(rate)
        return val
234193
def rigthgen(self, value=0):
        """"""
        while True:
            yield self.newarray(self.nplanes_right * self.width, value)
736637
protected static void incrementalUpdateMean(double[] mean, NumberVector vec, int newsize, double op) {
    if(newsize == 0) {
      return; // Keep old mean
    }
    // Note: numerically stabilized version:
    VMath.plusTimesEquals(mean, VMath.minusEquals(vec.toArray(), mean), op / newsize);
  }
1287129
def generate_single_seasonal_average(args):
    
    qout_file = args[0]
    seasonal_average_file = args[1]
    day_of_year = args[2]
    mp_lock = args[3]

    min_day = day_of_year - 3
    max_day = day_of_year + 3

    with RAPIDDataset(qout_file) as qout_nc_file:
        time_indices = []
        for idx, t in enumerate(qout_nc_file.get_time_array()):
            var_time = gmtime(t)
            compare_yday = var_time.tm_yday
            # move day back one past because of leap year adds
            # a day after feb 29 (day 60)
            if isleap(var_time.tm_year) and compare_yday > 60:
                compare_yday -= 1
            # check if date within range of season
            if max_day > compare_yday >= min_day:
                time_indices.append(idx)

        if not time_indices:
            raise IndexError("No time steps found within range ...")

        streamflow_array = qout_nc_file.get_qout(time_index_array=time_indices)

    avg_streamflow_array = np.mean(streamflow_array, axis=1)
    std_streamflow_array = np.std(streamflow_array, axis=1)
    max_streamflow_array = np.amax(streamflow_array, axis=1)
    min_streamflow_array = np.min(streamflow_array, axis=1)

    mp_lock.acquire()
    seasonal_avg_nc = Dataset(seasonal_average_file, 'a')
    seasonal_avg_nc.variables['average_flow'][:, day_of_year-1] = \
        avg_streamflow_array
    seasonal_avg_nc.variables['std_dev_flow'][:, day_of_year-1] = \
        std_streamflow_array
    seasonal_avg_nc.variables['max_flow'][:, day_of_year-1] = \
        max_streamflow_array
    seasonal_avg_nc.variables['min_flow'][:, day_of_year-1] = \
        min_streamflow_array
    seasonal_avg_nc.close()
    mp_lock.release()
166370
public static double Kurtosis(int[] values, double mean, double stdDeviation){
        double n = 0;
        for (int i = 0; i < values.length; i++)
            n += values[i];
        
        double part1 = n * (n + 1);
        part1 /= ((n - 1) * (n - 2) * (n - 3));
        
        double part2 = 0;
        for (int i = 0; i < values.length; i++) {
            part2 += Math.pow((i - mean) / stdDeviation, 4) * values[i];
        }
        
        double part3 = 3 * Math.pow((n - 1), 2);
        part3 /= (n - 2) * (n - 3);
        
        return part1 * part2 - part3;
    }
476169
def eval_mean(self, func, args=()):
        """"""
        self.fmean = func(self.mean, *args)
        return self.fmean
247081
def calc_average_parameters(parameter_layers):
        
        mean_layers = [numpy.mean(x) if x[0] else 0 for x in parameter_layers]
        overall_mean = numpy.mean([x for x in mean_layers if x])
        return mean_layers, overall_mean
130822
public static function variance(array $values, ?float $mean = null, ?int $n = null) : float
    {
        $n = $n ?? count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Variance is undefined for an'
                . ' empty set.');
        }

        $mean = $mean ?? self::mean($values);

        $ssd = 0.;

        foreach ($values as $value) {
            $ssd += ($value - $mean) ** 2;
        }

        return $ssd / $n;
    }
674735
function(mean, variance) {
    if (variance <= 0) {
      throw new Error('Variance must be > 0 (but was ' + variance + ')');
    }
    this.mean = mean;
    this.variance = variance;
    this.standardDeviation = Math.sqrt(variance);
  }