Evaluate the _unnormalized_ flow PDF.
546408
def _pdf(self, phi):
        
        pdf = np.inner(self._vn, np.cos(np.outer(phi, self._n)))
        pdf *= 2.
        pdf += 1.

        return pdf
26298
def _pdf(self, **kwargs):
        
        if kwargs not in self:
            return 0.
        return self._norm * \
            self._dfunc(numpy.array([kwargs[p] for p in self._params])).prod()
1292684
def softmax_to_unary(sm, GT_PROB=1):
    """"""
    warning("pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.")
    scale = None if GT_PROB == 1 else GT_PROB
    return unary_from_softmax(sm, scale, clip=None)
798204
def eval_unx(self, exp):
    ""
    inner=self.eval(exp.val)
    if exp.op.op=='+': return inner
    elif exp.op.op=='-': return -inner
    elif exp.op.op=='not': return threevl.ThreeVL.nein(inner)
    else: raise NotImplementedError('unk_op',exp.op)
1125657
def sample(self, multiplicity):
        

        """
        if self._n is None:
            return self._uniform_phi(multiplicity)

        # Since the flow PDF does not have an analytic inverse CDF, I use a
        # simple accept-reject sampling algorithm.  This is reasonably
        # efficient since for normal-sized vn, the PDF is close to flat.  Now
        # due to the overhead of Python functions, it's desirable to minimize
        # the number of calls to the random number generator.  Therefore I
        # sample numbers in chunks; most of the time only one or two chunks
        # should be needed.  Eventually, I might rewrite this with Cython, but
        # it's fast enough for now.

        N = 0  # number of phi that have been sampled
        phi = np.empty(multiplicity)  # allocate array for phi
        pdf_max = 1 + 2*self._vn.sum()  # sampling efficiency ~ 1/pdf_max

        while N < multiplicity:
            n_remaining = multiplicity - N
            n_to_sample = int(1.03*pdf_max*n_remaining)
            phi_chunk = self._uniform_phi(n_to_sample)
            phi_chunk = phi_chunk[self._pdf(phi_chunk) >
                                  np.random.uniform(0, pdf_max, n_to_sample)]
            K = min(phi_chunk.size, n_remaining)  # number of phi to take
            phi[N:N+K] = phi_chunk[:K]
            N += K

        return phi
908967
def evaluate(x, amplitude, mean, stddev):
        
        return 1.0 - Gaussian1D.evaluate(x, amplitude, mean, stddev)
1281840
def pdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)    
        return self.pdf_internal(mu, df=self.df0, loc=self.loc0, scale=self.scale0, gamma=self.gamma0)
1047550
def _evaluate(self, indices, norm_distances, out=None):
        """"""
        # slice for broadcasting over trailing dimensions in self.values
        vslice = (slice(None),) + (None,) * (self.values.ndim - len(indices))

        if out is None:
            out_shape = out_shape_from_meshgrid(norm_distances)
            out_dtype = self.values.dtype
            out = np.zeros(out_shape, dtype=out_dtype)
        else:
            out[:] = 0.0

        # Weights and indices (per axis)
        low_weights, high_weights, edge_indices = _create_weight_edge_lists(
            indices, norm_distances, self.schemes, self.nn_variants)

        # Iterate over all possible combinations of [i, i+1] for each
        # axis, resulting in a loop of length 2**ndim
        for lo_hi, edge in zip(product(*([['l', 'h']] * len(indices))),
                               product(*edge_indices)):
            weight = 1.0
            # TODO: determine best summation order from array strides
            for lh, w_lo, w_hi in zip(lo_hi, low_weights, high_weights):

                # We don't multiply in-place to exploit the cheap operations
                # in the beginning: sizes grow gradually as following:
                # (n, 1, 1, ...) -> (n, m, 1, ...) -> ...
                # Hence, it is faster to build up the weight array instead
                # of doing full-size operations from the beginning.
                if lh == 'l':
                    weight = weight * w_lo
                else:
                    weight = weight * w_hi
            out += np.asarray(self.values[edge]) * weight[vslice]
        return np.array(out, copy=False, ndmin=1)
1363963
def norm(x, mu, sigma=1.0):
    
    return stats.norm(loc=mu, scale=sigma).pdf(x)
52973
def normalize(self, inplace=True):
        
        phi = self if inplace else self.copy()

        # The pdf of a Joint Gaussian distrinution is always
        # normalized. Hence, no changes.
        if not inplace:
            return phi
971504
def re_rect(FlowRate, Width, DistCenter, Nu, openchannel):
    """"""
    #Checking input validity - inputs not checked here are checked by
    #functions this function calls.
    ut.check_range([FlowRate, ">0", "Flow rate"], [Nu, ">0", "Nu"])
    return (4 * FlowRate
            * radius_hydraulic(Width, DistCenter, openchannel).magnitude
            / (Width * DistCenter * Nu))
1158704
def evaluate(self, data):
        """"""
        return 'PYTHONPATH="{runtime}" python3 -u -m resolwe.process {program} --slug {slug} --inputs {inputs}'.format(
            runtime=PYTHON_RUNTIME_VOLUME,
            program=PYTHON_PROGRAM_VOLUME,
            slug=shlex.quote(data.process.slug),
            inputs=PYTHON_INPUTS_VOLUME,
        )
673195
def _pdf(self, xloc, dist, cache):
        """"""
        return evaluation.evaluate_density(dist, -xloc, cache=cache)
403101
def pdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)    
        if mu < self.lower and self.lower is not None:
            return 0.0
        elif mu > self.upper and self.upper is not None:
            return 0.0       
        else:
            return (1/float(self.sigma0))*np.exp(-(0.5*(mu-self.mu0)**2)/float(self.sigma0**2))
792744
def evaluate_unop(self, operation, right, **kwargs):
        
        if not operation in self.unops:
            raise ValueError("Invalid unary operation '{}'".format(operation))
        if right is None:
            return None
        return self.unops[operation](right)
419020
def _logpdf(self, **kwargs):
        
        if kwargs not in self:
            return -numpy.inf
        return self._lognorm + \
            numpy.log(self._dfunc(
                numpy.array([kwargs[p] for p in self._params]))).sum()
1290059
def _evaluate(x, y, weights):
    '''
    
    '''
    i = _validI(x, y, weights)
    xx = x[i]
    y = y[i]

    try:
        fitParams = _fit(xx, y)
        # bound noise fn to min defined y value:
        minY = function(xx[0], *fitParams)
        fitParams = np.insert(fitParams, 0, minY)
        fn = lambda x, minY=minY: boundedFunction(x, *fitParams)
    except RuntimeError:
        print(
            "couldn't fit noise function with filtered indices, use polynomial fit instead")
        fitParams = None
        fn = smooth(xx, y, weights[i])
    return fitParams, fn, i