# sc_math#

Extensions to Numpy, including finding array elements and smoothing data.

Highlights:

Functions

 `approx` Determine whether two scalars (or an array and a scalar) approximately match. `safedivide` Handle divide-by-zero and divide-by-nan elegantly. `findinds` Find matches even if two things aren't eactly equal (e.g. floats vs. `findfirst` Alias for `sc.findinds(..., first=True)`. `findlast` Alias for `sc.findinds(..., last=True)`. `findnearest` Return the index of the nearest match in series to value -- like `sc.findinds()`, but always returns an object with the same type as value (i.e. findnearest with a number returns a number, findnearest with an array returns an array). `count` Count the number of matching elements. `dataindex` Take an array of data and return either the first or last (or some other) non-NaN entry. `getvalidinds` Return the indices that are valid based on the validity of the input data from an arbitrary number of 1-D vector inputs. `getvaliddata` Return the data value indices that are valid based on the validity of the input data. `sanitize` Sanitize input to remove NaNs. `rmnans` Sanitize input to remove NaNs. `fillnans` Alias for `sc.sanitize(..., replacenans=True)` with nearest interpolation (or a specified value). `findnans` Alias for `sc.findinds(np.isnan(data))`. `nanequal` Compare two or more arrays for equality element-wise, treating NaN values as equal. `isprime` Determine if a number is prime. `numdigits` Count the number of digits in a number (or list of numbers). `perturb` Define an array of numbers uniformly perturbed with a mean of 1. `normsum` Multiply a list or array by some normalizing factor so that its sum is equal to the total. `normalize` Rescale an array between a minimum value and a maximum value. `inclusiverange` Like `numpy.arange()`/numpy.linspace, but includes the start and stop points. `randround` Round a float, list, or array probabilistically to the nearest integer. `cat` Like `numpy.concatenate()`, but takes anything and returns an array. `linregress` Simple linear regression returning the line of best fit and R value. `rolling` Alias to `pandas.Series.rolling()` (window) method to smooth a series. `convolve` Like `numpy.convolve()`, but always returns an array the size of the first array (equivalent to mode='same'), and solves the boundary problem present in `numpy.convolve()` by adjusting the edges by the weight of the convolution kernel. `smooth` Very simple function to smooth a 1D or 2D array. `smoothinterp` Smoothly interpolate over values `gauss1d` Gaussian 1D smoothing kernel. `gauss2d` Gaussian 2D smoothing kernel.