returns the N first approximations to the 2d function h
    whose sum should be h
502498
def _separable_approx2(h, N=1):
    
    return np.cumsum([np.outer(fy, fx) for fy, fx in _separable_series2(h, N)], 0)
380457
def compute_number_edges(function):
    
    n = 0
    for node in function.nodes:
        n += len(node.sons)
    return n
1189467
def _densMoments_approx_higherorder_gaussxpolyInts(self,ll,ul,maxj):
        """"""
        gaussxpolyInt= numpy.zeros((maxj,len(ul)))
        gaussxpolyInt[-1]= 1./numpy.sqrt(numpy.pi)\
            *(numpy.exp(-ll**2.)-numpy.exp(-ul**2.))
        gaussxpolyInt[-2]= 1./numpy.sqrt(numpy.pi)\
            *(numpy.exp(-ll**2.)*ll-numpy.exp(-ul**2.)*ul)\
            +0.5*(special.erf(ul)-special.erf(ll))
        for jj in range(maxj-2):
            gaussxpolyInt[-jj-3]= 1./numpy.sqrt(numpy.pi)\
            *(numpy.exp(-ll**2.)*ll**(jj+2)-numpy.exp(-ul**2.)*ul**(jj+2))\
            +0.5*(jj+2)*gaussxpolyInt[-jj-1]
        return gaussxpolyInt
154787
def sample_function(self, f, N):
        
        x = self.interpolation_points(N+1)
        return f(x)
360705
def _minimize_constraints_fun_summation(x):
    '''
    
    '''
    summation = sum([x[i] for i in CONSTRAINT_PARAMS_IDX])
    return CONSTRAINT_UPPERBOUND >= summation >= CONSTRAINT_LOWERBOUND
285920
def prior_draw(self, N=1):
        
        p = np.random.ranf(size=(N, self.ndim))
        p = (self._upper_right - self._lower_left) * p + self._lower_left
        return p
1317574
def euclidean(h1, h2): # 9 us @array, 33 us @list \w 100 bins
    
    """
    h1, h2 = __prepare_histogram(h1, h2)
    return math.sqrt(scipy.sum(scipy.square(scipy.absolute(h1 - h2))))
1256887
def H5(self):
        ""
        t = 1 + toeplitz(self.levels) ** 2
        repeated = np.tile(t[np.newaxis], (self.nobjects, 1, 1))
        return (1.0 / repeated * self.P).sum(2).sum(1)
1009060
def _function(self, x, a, b, c, d):
        
        return c/((a**2-x**2)**2 + (b*x)**2)+d
794637
def bezier_curve_approx_len(P=[(0.0, 0.0)]):
    '''
    '''
    assert isinstance(P, list)
    assert len(P) > 0
    for p in P:
        assert isinstance(p, tuple)
        for i in p:
            assert len(p) > 1
            assert isinstance(i, float)
    
    n_seg = len(P) - 1
    pts = pts_on_bezier_curve(P, n_seg)
    return sum([distance_between_pts(pts[i], pts[i+1]) for i in range(n_seg)])
129479
private void computeDandH( DenseMatrix64F param , DenseMatrix64F x , DenseMatrix64F y )
    {
        func.compute(param,x, tempDH);
        subtractEquals(tempDH, y);

        if (jacobianFactory != null)
        {
            jacobianFactory.computeJacobian(param, x, jacobian);
        }
        else
        {
            computeNumericalJacobian(param,x,jacobian);
        }

        int numParam = param.getNumElements();
        int length = y.getNumElements();

        // d = average{ (f(x_i;p) - y_i) * jacobian(:,i) }
        for( int i = 0; i < numParam; i++ ) {
            double total = 0;
            for( int j = 0; j < length; j++ ) {
                total += tempDH.get(j,0)*jacobian.get(i,j);
            }
            d.set(i,0,total/length);
        }

        // compute the approximation of the hessian
        multTransB(jacobian,jacobian,H);
        scale(1.0/length,H);
    }
36960
def _separable_approx3(h, N=1):
    
    return np.cumsum([np.einsum("i,j,k", fz, fy, fx) for fz, fy, fx in _separable_series3(h, N)], 0)
805465
function (m, u) {
        return [
            m[0][0] * u[0] + m[0][1] * u[1] + m[0][2] * u[2],
            m[1][0] * u[0] + m[1][1] * u[1] + m[1][2] * u[2],
            m[2][0] * u[0] + m[2][1] * u[1] + m[2][2] * u[2]
        ];
    }
1262309
def H10(self):
        ""
        c = (self.rlevels * self.p_xminusy).sum(1)
        c1 = np.tile(c, (self.nlevels,1)).transpose()
        e = self.rlevels - c1
        return (self.p_xminusy * e ** 2).sum(1)
275521
def sbesselh1(x, N):
    ""
    
    jn = sbesselj(x, N)
    yn = sbessely(x, N)

    return jn + 1j * yn
148270
def n_elements(self):
        
        if self.is_array:
            return functools.reduce(operator.mul, self.array_dimensions)
        else:
            return 1
496026
def sbesselh2(x, N):
    ""

    jn = sbesselj(x, N)
    yn = sbessely(x, N)

    return jn - 1j * yn