sc_math#
Extensions to Numpy, including finding array elements and smoothing data.
- Highlights:
sc.findinds()
: find indices of an array matching a conditionsc.findnearest()
: find nearest matching valuesc.rolling()
: calculate rolling averagesc.smooth()
: simple smoothing of 1D or 2D arrays
Functions
Determine whether two scalars (or an array and a scalar) approximately match. |
|
Handle divide-by-zero and divide-by-nan elegantly. |
|
Find matches even if two things aren't eactly equal (e.g. |
|
Alias for findinds(..., first=True). |
|
Alias for findinds(..., last=True). |
|
Return the index of the nearest match in series to value -- like findinds, but always returns an object with the same type as value (i.e. |
|
Count the number of matching elements. |
|
Take an array of data and return either the first or last (or some other) non-NaN entry. |
|
Return the indices that are valid based on the validity of the input data from an arbitrary number of 1-D vector inputs. |
|
Sanitize input to remove NaNs. |
|
Sanitize input to remove NaNs. |
|
Alias for |
|
Alias for |
|
Return the data value indices that are valid based on the validity of the input data. |
|
Determine if a number is prime. |
|
Count the number of digits in a number (or list of numbers). |
|
Define an array of numbers uniformly perturbed with a mean of 1. |
|
Multiply a list or array by some normalizing factor so that its sum is equal to the total. |
|
Rescale an array between a minimum value and a maximum value. |
|
Like |
|
Round a float, list, or array probabilistically to the nearest integer. |
|
Like np.concatenate(), but takes anything and returns an array. |
|
Simple linear regression returning the line of best fit and R value. |
|
Alias to pandas' rolling() (window) method to smooth a series. |
|
Like |
|
Very simple function to smooth a 1D or 2D array. |
|
Smoothly interpolate over values |
|
Gaussian 1D smoothing kernel. |
|
Gaussian 2D smoothing kernel. |