Creates the weights for the tapered method. See func: teneto.derive.derive.
515417
def _weightfun_tapered_sliding_window(T, params, report):
    
    x = np.arange(-(params['windowsize'] - 1) / 2, (params['windowsize']) / 2)
    distribution_parameters = ','.join(map(str, params['distribution_params']))
    taper = eval('sps.' + params['distribution'] +
                             '.pdf(x,' + distribution_parameters + ')')

    weightat0 = np.zeros(T)
    weightat0[0:params['windowsize']] = taper
    weights = np.array([np.roll(weightat0, i)
                        for i in range(0, T + 1 - params['windowsize'])])
    report['method'] = 'slidingwindow'
    report['slidingwindow'] = params
    report['slidingwindow']['taper'] = taper
    report['slidingwindow']['taper_window'] = x
    return weights, report
205334
def _expand(self, coeffsin, nmax):
        
        falpha = _shtools.SlepianCoeffs(self.tapers, coeffsin, nmax)

        return SlepianCoeffs(falpha, self)
755970
private Data<Input, Output> derive_(Input input) {
        Data<Input, Output> result = new Data<>(input, fn_.apply(input));
        recent_.set(result);
        return result;
    }
612678
def assign_step_methods(self, verbose=-1, draw_from_prior_when_possible=True):
        

        if not self._sm_assigned:

            if draw_from_prior_when_possible:
                # Assign dataless stepper first
                last_gen = set([])
                for s in self.stochastics - self.observed_stochastics:
                    if s._random is not None:
                        if len(s.extended_children) == 0:
                            last_gen.add(s)

                dataless, dataless_gens = crawl_dataless(
                    set(last_gen), [last_gen])
                if len(dataless):
                    new_method = DrawFromPrior(
                        dataless,
                        dataless_gens[::-1],
                        verbose=verbose)
                    setattr(new_method, '_model', self)
                    for d in dataless:
                        if not d.observed:
                            self.step_method_dict[d].append(new_method)
                            if self.verbose > 1:
                                print_(
                                    'Assigning step method %s to stochastic %s' %
                                    (new_method.__class__.__name__, d.__name__))

            for s in self.stochastics:
                # If not handled by any step method, make it a new step method
                # using the registry
                if len(self.step_method_dict[s]) == 0:
                    new_method = assign_method(s, verbose=verbose)
                    setattr(new_method, '_model', self)
                    self.step_method_dict[s].append(new_method)
                    if self.verbose > 1:
                        print_(
                            'Assigning step method %s to stochastic %s' %
                            (new_method.__class__.__name__, s.__name__))

            self.step_methods = set()
            for s in self.stochastics:
                self.step_methods |= set(self.step_method_dict[s])

            for sm in self.step_methods:
                if sm.tally:
                    for name in sm._tuning_info:
                        self._funs_to_tally[
                            sm._id + '_' + name] = lambda name=name, sm=sm: getattr(sm, name)

        else:
            # Change verbosity for step methods
            for sm_key in self.step_method_dict:
                for sm in self.step_method_dict[sm_key]:
                    sm.verbose = verbose

        self.restore_sm_state()
        self._sm_assigned = True
175506
def init_weights(self):
        """"""

        self.W = np.random.randn(self.n_neurons, self.n_inputs) * np.sqrt(2 / self.n_inputs)
        self.b = np.zeros((self.n_neurons, 1))
912796
def _construct_X_M(self, omega, **kwargs):
        """"""
        X = self._construct_X(omega, weighted=True, **kwargs)
        M = np.dot(X.T, X)

        if getattr(self, 'regularization', None) is not None:
            diag = M.ravel(order='K')[::M.shape[0] + 1]
            if self.regularize_by_trace:
                diag += diag.sum() * np.asarray(self.regularization)
            else:
                diag += np.asarray(self.regularization)

        return X, M
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;
    }
247529
protected void computePointsAndWeights(double slopeX, double slopeY, double x0, double y0, double tanX, double tanY) {

		samplePts.reset();
		weights.reset();
		int numSamples = radialSamples*2+2;
		int numPts = numSamples-1;
		double widthX = numSamples*tanX;
		double widthY = numSamples*tanY;

		for (int i = 0; i < lineSamples; i++ ) {
			// find point on line and shift it over to the first sample point
			double frac = i/(double)(lineSamples -1);
			double x = x0 + slopeX*frac-widthX/2.0;
			double y = y0 + slopeY*frac-widthY/2.0;

			// Unless all the sample points are inside the image, ignore this point
			if(!integral.isInside(x, y) || !integral.isInside(x + widthX,y + widthY))
				continue;

			double sample0 = integral.compute(x, y, x + tanX, y + tanY);
			x += tanX; y += tanY;
			for (int j = 0; j < numPts; j++) {
				double sample1 = integral.compute(x, y, x + tanX, y + tanY);

				double w = sample0 - sample1;
				if( w < 0 ) w = -w;

				if( w > 0 ) {
					weights.add(w);
					samplePts.grow().set((x - center.x) / localScale, (y - center.y) / localScale);
				}

				x += tanX; y += tanY;
				sample0 = sample1;
			}
		}
	}
201083
def _construct_X(self, omega, weighted=True, **kwargs):
        """"""
        t = kwargs.get('t', self.t)
        dy = kwargs.get('dy', self.dy)
        fit_offset = kwargs.get('fit_offset', self.fit_offset)

        if fit_offset:
            offsets = [np.ones(len(t))]
        else:
            offsets = []

        cols = sum(([np.sin((i + 1) * omega * t),
                     np.cos((i + 1) * omega * t)]
                    for i in range(self.Nterms)), offsets)

        if weighted:
            return np.transpose(np.vstack(cols) / dy)
        else:
            return np.transpose(np.vstack(cols))
852694
def create(entropy_coefficient, value_coefficient, cliprange, max_grad_norm, discount_factor,
           normalize_advantage=True, gae_lambda=1.0):
    
    return PpoPolicyGradient(
        entropy_coefficient, value_coefficient, cliprange, max_grad_norm,
        discount_factor=discount_factor,
        normalize_advantage=normalize_advantage,
        gae_lambda=gae_lambda
    )
739754
def set_weights(params, new_params):
        
        for param, new_param in zip(params, new_params):
            param.data.copy_(new_param.data)
1222303
def lp10(self, subset_k, subset_p, weights={}):
        

        if self._z is None:
            self._add_minimization_vars()

        positive = set(subset_k) - self._flipped
        negative = set(subset_k) & self._flipped

        v = self._v.set(positive)
        cs = self._prob.add_linear_constraints(v >= self._epsilon)
        self._temp_constr.extend(cs)

        v = self._v.set(negative)
        cs = self._prob.add_linear_constraints(v <= -self._epsilon)
        self._temp_constr.extend(cs)

        self._prob.set_objective(self._z.expr(
            (rxnid, -weights.get(rxnid, 1)) for rxnid in subset_p))

        self._solve()
1053841
def _add_existing_weight(self, weight, trainable=None):
    """"""
    if trainable is None: trainable = weight.trainable
    self.add_weight(name=weight.name, shape=weight.shape, dtype=weight.dtype,
                    trainable=trainable, getter=lambda *_, **__: weight)
1161413
@Override
  public SpanWeight createWeight(IndexSearcher searcher, boolean needsScores, float boost)
      throws IOException {
    final TermContext context;
    final IndexReaderContext topContext = searcher.getTopReaderContext();
    if (termContext == null) {
      context = TermContext.build(topContext, localTerm);
    } else {
      context = termContext;
    }
    return new SpanTermWeight(context, searcher,
        needsScores ? Collections.singletonMap(localTerm, context) : null, boost);
  }
236395
public static WeightedIntDiGraph fromUnweighted(IntDiGraph g, Function<DiEdge, Double> makeDefaultWeight) {
        WeightedIntDiGraph wg = new WeightedIntDiGraph(makeDefaultWeight);
        wg.addAll(g);
        return wg;
    }
189547
def _create_peephole_variables(self, dtype):
    """"""
    self._w_f_diag = tf.get_variable(
        self.W_F_DIAG,
        shape=[self._hidden_size],
        dtype=dtype,
        initializer=self._initializers.get(self.W_F_DIAG),
        partitioner=self._partitioners.get(self.W_F_DIAG),
        regularizer=self._regularizers.get(self.W_F_DIAG))
    self._w_i_diag = tf.get_variable(
        self.W_I_DIAG,
        shape=[self._hidden_size],
        dtype=dtype,
        initializer=self._initializers.get(self.W_I_DIAG),
        partitioner=self._partitioners.get(self.W_I_DIAG),
        regularizer=self._regularizers.get(self.W_I_DIAG))
    self._w_o_diag = tf.get_variable(
        self.W_O_DIAG,
        shape=[self._hidden_size],
        dtype=dtype,
        initializer=self._initializers.get(self.W_O_DIAG),
        partitioner=self._partitioners.get(self.W_O_DIAG),
        regularizer=self._regularizers.get(self.W_O_DIAG))
205712
def _setweights(self):
        ""
        for layer in self.layer_names:
            raw_w = getattr(self, f'{layer}_raw')
            self.module._parameters[layer] = F.dropout(raw_w, p=self.weight_p, training=self.training)