Compute derivative of kernel for dimension wrt lengthscale
		Computation of derivative changes when lengthscale corresponds to
		the dimension of the kernel whose derivate is being computed.
347937
def dKdLen_of_r(self, r, dimCheck, lengthscale):
		
		if (dimCheck == True):
			return (self.variance**(float(1)/self.originalDimensions)) * np.exp(-0.5 * r**2) * (r**2) / (lengthscale**(float(1)/self.originalDimensions))
		else:
			return (self.variance**(float(1)/self.originalDimensions)) * np.exp(-0.5 * r**2) / (lengthscale**(float(1)/self.originalDimensions))
38561
def gradient(self):
        """"""
        functional = self
        c = self.scale

        class RosenbrockGradient(Operator):

            """The gradient operator of the Rosenbrock functional."""

            def __init__(self):
                """Initialize a new instance."""
                super(RosenbrockGradient, self).__init__(
                    functional.domain, functional.domain, linear=False)

            def _call(self, x, out):
                """Apply the gradient operator to the given point."""
                for i in range(1, self.domain.size - 1):
                    out[i] = (2 * c * (x[i] - x[i - 1]**2) -
                              4 * c * (x[i + 1] - x[i]**2) * x[i] -
                              2 * (1 - x[i]))
                out[0] = (-4 * c * (x[1] - x[0] ** 2) * x[0] +
                          2 * (x[0] - 1))
                out[-1] = 2 * c * (x[-1] - x[-2] ** 2)

            def derivative(self, x):
                """The derivative of the gradient.

                This is also known as the Hessian.
                """
                # TODO: Implement optimized version of this that does not need
                # a matrix.
                shape = (functional.domain.size, functional.domain.size)
                matrix = np.zeros(shape)

                # Straightforward computation
                for i in range(0, self.domain.size - 1):
                    matrix[i, i] = (2 * c + 2 + 12 * c * x[i] ** 2 -
                                    4 * c * x[i + 1])
                    matrix[i + 1, i] = -4 * c * x[i]
                    matrix[i, i + 1] = -4 * c * x[i]
                matrix[-1, -1] = 2 * c
                matrix[0, 0] = 2 + 12 * c * x[0] ** 2 - 4 * c * x[1]
                return MatrixOperator(matrix, self.domain, self.range)

        return RosenbrockGradient()
687079
def _dK_dR(self, R):
        """"""
        return -self._ns * self._N / R**2 / self._sin_alpha
786755
def fit_deriv(x, amplitude, mean, stddev):
        
        import operator
        return list(map(
            operator.neg, Gaussian1D.fit_deriv(x, amplitude, mean, stddev)))
476087
def d(self, xi):
        """"""
        return self.__basis(xi, self.p, compute_derivatives=True)
1083201
def _derY(self,x,y,z):
        '''
        
        '''
        if _isscalar(x):
            z_pos = max(min(np.searchsorted(self.z_list,z),self.z_n-1),1)
            alpha = (z - self.z_list[z_pos-1])/(self.z_list[z_pos] - self.z_list[z_pos-1])
            dfdy = (1-alpha)*self.xyInterpolators[z_pos-1].derivativeY(x,y) + alpha*self.xyInterpolators[z_pos].derivativeY(x,y)
        else:
            m = len(x)
            z_pos = np.searchsorted(self.z_list,z)
            z_pos[z_pos > self.z_n-1] = self.z_n-1
            z_pos[z_pos < 1] = 1
            dfdy = np.zeros(m) + np.nan
            if x.size > 0:
                for i in range(1,self.z_n):
                    c = z_pos == i
                    if np.any(c):
                        alpha = (z[c] - self.z_list[i-1])/(self.z_list[i] - self.z_list[i-1])
                        dfdy[c] = (1-alpha)*self.xyInterpolators[i-1].derivativeY(x[c],y[c]) + alpha*self.xyInterpolators[i].derivativeY(x[c],y[c])
        return dfdy
663850
def gradient(self):
        """"""
        return (ScalingOperator(self.domain, 1 / self.sigma) -
                (1 / self.sigma) * self.functional.proximal(self.sigma))
455576
function gaussianKernel1D(s, n) {
    if (typeof n !== 'number') n = 7;
    var kernel = new Float64Array(n),
        halfN = Math.floor(n * 0.5),
        odd = n % 2,
        i;
    if (!s || !n) return kernel;
    for (i = 0; i <= halfN; i++) {
        kernel[i] = gauss(s * (i - halfN - odd * 0.5), s);
    }
    for (; i < n; i++) {
        kernel[i] = kernel[n - 1 - i];
    }
    return kernel;
}
693066
def deriv(self, n=1):
        
        if n==1:
            if self.order > 0:
                return PowerSeries(self.c[1:]*range(1,len(self.c)))
            else:
                return PowerSeries([0. * self.c[0]])
        elif n>1:
            return self.deriv().deriv(n-1)
        elif n==0:
            return self
421923
def _compute_ndim(row_loc, col_loc):
    
    row_scaler = is_scalar(row_loc)
    col_scaler = is_scalar(col_loc)

    if row_scaler and col_scaler:
        ndim = 0
    elif row_scaler ^ col_scaler:
        ndim = 1
    else:
        ndim = 2

    return ndim
71446
def derivative(xdata, ydata):
    
    D_ydata = []
    D_xdata = []
    for n in range(1, len(xdata)-1):
        D_xdata.append(xdata[n])
        D_ydata.append((ydata[n+1]-ydata[n-1])/(xdata[n+1]-xdata[n-1]))

    return [D_xdata, D_ydata]
465238
def copy(self):
        """"""
        result = Scalar(self.size, self.deriv)
        result.v = self.v
        if self.deriv > 0: result.d[:] = self.d[:]
        if self.deriv > 1: result.dd[:] = self.dd[:]
        return result
541030
def derivatives_ctrlpts(**kwargs):
        
        r1 = kwargs.get('r1')  # minimum span on the u-direction
        r2 = kwargs.get('r2')  # maximum span on the u-direction
        s1 = kwargs.get('s1')  # minimum span on the v-direction
        s2 = kwargs.get('s2')  # maximum span on the v-direction

        deriv_order = kwargs.get('deriv_order')
        ctrlpts_size = kwargs.get('ctrlpts_size')
        degree = kwargs.get('degree')
        knotvector = kwargs.get('knotvector')
        ctrlpts = kwargs.get('ctrlpts')
        dimension = kwargs.get('dimension')

        PKL = [[[[[None for _ in range(dimension)]
                  for _ in range(ctrlpts_size[1])] for _ in range(ctrlpts_size[0])]
                for _ in range(deriv_order + 1)] for _ in range(deriv_order + 1)]

        du = min(degree[0], deriv_order)
        dv = min(degree[1], deriv_order)

        r = r2 - r1
        s = s2 - s1

        # Control points of the U derivatives of every U-curve
        for j in range(s1, s2 + 1):
            PKu = CurveEvaluator2.derivatives_ctrlpts(r1=r1, r2=r2,
                                                      degree=degree[0],
                                                      knotvector=knotvector[0],
                                                      ctrlpts=[ctrlpts[j + (ctrlpts_size[1] * i)] for i in range(ctrlpts_size[0])],
                                                      dimension=dimension,
                                                      deriv_order=du)

            # Copy into output as the U partial derivatives
            for k in range(0, du + 1):
                for i in range(0, r - k + 1):
                    PKL[k][0][i][j - s1] = PKu[k][i]

        # Control points of the V derivatives of every U-differentiated V-curve
        for k in range(0, du):
            for i in range(0, r - k + 1):
                dd = min(deriv_order - k, dv)

                PKuv = CurveEvaluator2.derivatives_ctrlpts(r1=0, r2=s,
                                                           degree=degree[1],
                                                           knotvector=knotvector[1][s1:],
                                                           ctrlpts=PKL[k][0][i],
                                                           dimension=dimension,
                                                           deriv_order=dd)

                # Copy into output
                for l in range(1, dd + 1):
                    for j in range(0, s - l + 1):
                        PKL[k][l][i][j] = PKuv[l][j]

        return PKL
428645
def ednde_deriv(self, x, params=None):
        """"""
        params = self.params if params is None else params
        return np.squeeze(self.eval_ednde_deriv(x, params, self.scale,
                                                self.extra_params))
1106800
def derivatives(self, **kwargs):
        
        # Call parent method
        super(CurveEvaluator2, self).derivatives(**kwargs)

        param = kwargs.get('parameter')
        deriv_order = kwargs.get('deriv_order', 0)
        degree = kwargs.get('degree')
        knotvector = kwargs.get('knotvector')
        ctrlpts = kwargs.get('ctrlpts')
        dimension = kwargs.get('dimension')

        # Algorithm A3.4
        du = min(degree, deriv_order)

        CK = [[0.0 for _ in range(dimension)] for _ in range(deriv_order + 1)]

        span = self._span_func(degree, knotvector, len(ctrlpts), param)
        bfuns = helpers.basis_function_all(degree, tuple(knotvector), span, param)

        # "derivatives_ctrlpts" is a static method that could be called like below
        PK = CurveEvaluator2.derivatives_ctrlpts(r1=(span - degree), r2=span,
                                                 degree=degree,
                                                 knotvector=knotvector,
                                                 ctrlpts=ctrlpts,
                                                 dimension=dimension,
                                                 deriv_order=du)

        for k in range(0, du + 1):
            for j in range(0, degree - k + 1):
                CK[k][:] = [elem + (bfuns[j][degree - k] * drv_ctl_p) for elem, drv_ctl_p in
                            zip(CK[k], PK[k][j])]

        # Return the derivatives
        return CK
292715
def _compute_derivatives(self):
        
        derivatives = []
        for i, (timestamp, value) in enumerate(self.time_series_items):
            if i > 0:
                pre_item = self.time_series_items[i - 1]
                pre_timestamp = pre_item[0]
                pre_value = pre_item[1]
                td = timestamp - pre_timestamp
                derivative = (value - pre_value) / td if td != 0 else value - pre_value
                derivative = abs(derivative)
                derivatives.append(derivative)
        # First timestamp is assigned the same derivative as the second timestamp.
        if derivatives:
            derivatives.insert(0, derivatives[0])
        self.derivatives = derivatives
409877
def derivatives(self, x, y, kappa_ext, ra_0=0, dec_0=0):
        
        x_ = x - ra_0
        y_ = y - dec_0
        f_x = kappa_ext * x_
        f_y = kappa_ext * y_
        return f_x, f_y