Smooth y-values and return new x, y pair.
510421
def smooth(x, y, degree=3):
    """"""

    if degree == 1:
        return x, y
    elif not isodd(degree):
        raise ValueError("Degree must be an odd number")
    else:
        window_width = int(degree / 2)
        data_size = len(y) - degree + 1

        smoothed_y = np.zeros(data_size)
        for idx in range(degree):
            smoothed_y += y[idx:idx + data_size]
        smoothed_y /= degree

        smoothed_x = x[window_width:-window_width]

        return smoothed_x, smoothed_y
744517
def fit(self, X, y):
        """"""

        self._data = X
        self._classes = np.unique(y)
        self._labels = y
        self._is_fitted = True
1035235
def fit(self, X, y, n_iter=None):
        """"""
        self.n_iter = self.n_iter if n_iter is None else n_iter
        X = getattr(X, 'values', X).reshape(len(X), 1)
        X_1 = self.homogenize(X)
        for i in range(self.n_iter):
            for i in range(0, len(X), 10):  # minibatch learning for numerical stability
                batch = slice(i, min(i + 10, len(X)))
                Xbatch, ybatch = X[batch, :], y[batch]
                X_1_batch = X_1[batch, :]
                self.W += (self.alpha / len(X) ** 1.5) * (
                    self.delta(Xbatch, ybatch).reshape((len(Xbatch), 1)).T.dot(X_1_batch))
        return self
642985
def run_friedman_smooth(x, y, span):
    """"""
    N = len(x)
    weight = numpy.ones(N)
    results = numpy.zeros(N)
    residuals = numpy.zeros(N)
    mace.smooth(x, y, weight, span, 1, 1e-7, results, residuals)
    return results, residuals
37104
def _smooth(series, window_len, window):
    """"""

    windows = {
        "flat": np.ones,
        "hanning": np.hanning,
        "hamming": np.hamming,
        "bartlett": np.bartlett,
        "blackman": np.blackman,
    }
    data = series.values.copy()

    if window_len < 3:
        return pd.Series(data, index=series.index, name=series.name)

    if window not in list(windows.keys()):
        raise ValueError(
            """window must be one of 'flat', 'hanning',
                         'hamming', 'bartlett', 'blackman'"""
        )

    s = np.r_[
        2 * data[0] - data[window_len:1:-1],
        data,
        2 * data[-1] - data[-1:-window_len:-1],
    ]

    w = windows[window](window_len)

    data = np.convolve(w / w.sum(), s, mode="same")
    data = data[window_len - 1 : -window_len + 1]
    return pd.Series(data, index=series.index, name=series.name)
1223021
def fit(self, X, y=None, **fit_params):
        
        if self.transform_type not in self.valid_transforms:
                warnings.warn("Invalid transform type.", stacklevel=2)
        return self
1265658
def normalizeY(value):
    
    if not isinstance(value, (int, float)):
        raise TypeError("Y coordinates must be instances of "
                        ":ref:`type-int-float`, not %s."
                        % type(value).__name__)
    return value
804790
def non_decreasing(values):
    """"""
    return all(x <= y for x, y in zip(values, values[1:]))
855592
def joint_hex(x, y, **kwargs):
    """"""
    return sns.jointplot(
        x, y, kind='hex', stat_func=None, marginal_kws={'kde': True}, **kwargs
    )
242877
def smooth_data(xdata, ydata, yerror, amount=1):
    

    new_xdata  = smooth_array(_n.array(xdata), amount)
    new_ydata  = smooth_array(_n.array(ydata), amount)
    if yerror is None:  new_yerror = None
    else:               new_yerror = smooth_array(_n.array(yerror), amount)

    return [new_xdata, new_ydata, new_yerror]
337925
private double SmoothedNoise(double x, double y) {
        int xInt = (int) x;
        int yInt = (int) y;
        double xFrac = x - xInt;
        double yFrac = y - yInt;

        // get four noise values
        double x0y0 = Noise(xInt, yInt);
        double x1y0 = Noise(xInt + 1, yInt);
        double x0y1 = Noise(xInt, yInt + 1);
        double x1y1 = Noise(xInt + 1, yInt + 1);

        // x interpolation
        double v1 = CosineInterpolate(x0y0, x1y0, xFrac);
        double v2 = CosineInterpolate(x0y1, x1y1, xFrac);
        // y interpolation
        return CosineInterpolate(v1, v2, yFrac);
    }
882213
def fit(self, X, y=None):
        
        for columns, transformer in self.mapping:
            if transformer is not None:
                transformer.fit(self._get_columns(X, columns))
        return self
592691
def smoothstep(edge0, edge1, x):
    
    # Scale, bias and saturate x to 0..1 range
    x = np.clip((x - edge0)/(edge1 - edge0), 0.0, 1.0)
    # Evaluate polynomial
    return x*x*(3 - 2*x)
1202790
def _create_s(y, h):
        """"""
        s = np.zeros_like(y)
        s[:-1] = (y[1:] - y[:-1]) / h[:-1]
        s[-1] = 0.0
        return s
815143
private float[] sobel(int x, int y) {
		int v00 = 0, v01 = 0, v02 = 0, v10 = 0, v12 = 0, v20 = 0, v21 = 0, v22 = 0;

		int x0 = x - 1, x1 = x, x2 = x + 1;
		int y0 = y - 1, y1 = y, y2 = y + 1;
		if (x0 < 0)
			x0 = 0;
		if (y0 < 0)
			y0 = 0;
		if (x2 >= width)
			x2 = width - 1;
		if (y2 >= height)
			y2 = height - 1;

		v00 = image[x0][y0];
		v10 = image[x1][y0];
		v20 = image[x2][y0];
		v01 = image[x0][y1];
		v21 = image[x2][y1];
		v02 = image[x0][y2];
		v12 = image[x1][y2];
		v22 = image[x2][y2];

		float sx = ((v20 + 2 * v21 + v22) - (v00 + 2 * v01 + v02)) / (1200f);
		float sy = ((v02 + 2 * v12 + v22) - (v00 + 2 * v10 + v20)) / (1200f);
		return new float[] { sx, sy };
	}
615266
function smoothFn (v, o, f, snap){
      v = !v ? 0 : v;
      f = f === undefined ? 0.1 : f;
      f = Math.min(f, snap);
      if (f < 0) { f = v > o ? Math.abs(snap) : -f; }
      return f * v + (1 - f) * o;
    }
1322840
def normalize(self):
        
        median_diff = np.median(np.diff(self.x))
        bin_edges = [self.x[0] - median_diff/2.0]
        bin_edges.extend(median_diff/2.0 + self.x)
        self.y_raw = self.y_raw/(self.y_raw.sum()*np.diff(bin_edges))
        self.smooth()