emgdecompy.contrast
Module Contents
Functions
|
Applies contrast function (if der=False) or |
|
Applies contrast function (if der=False) or |
|
Applies contrast function (if der=False) or |
|
Takes first derivitive and applies contrast function to w |
- emgdecompy.contrast.skew(w, der=False)[source]
Applies contrast function (if der=False) or first derivative of contrast function (if der=True) to w. skew = w^3 / 3
- Parameters
w (np.array) – Array to apply contrast function to.
der (boolean) – Whether to apply derivative (or base version).
- Returns
Array with contrast function applied, same shape as w.
- Return type
np.array
Examples
>>> w = np.array([1, 2, 3, 800]) >>> skew(w, der=True) array([1, 4, 9, 640000])
- emgdecompy.contrast.log_cosh(w, der=False)[source]
Applies contrast function (if der=False) or first derivative of contrast function (if der=True) to each element of w. function = log(cosh(w))
- Parameters
w (np.array) – Array to apply contrast function to.
der (boolean) – Whether to apply derivative (or base version).
- Returns
Array with contrast function applied, same shape as w.
- Return type
np.array
Examples
>>> w = np.array([1, 2, 3, 800]) >>> log_cosh(w) array([4.33780830e-01, 1.32500275e+00, 2.30932850e+00, 7.99300000e+02])
- emgdecompy.contrast.exp_sq(x, der=False)[source]
Applies contrast function (if der=False) or first derivative of contrast function (if der=True) to w. exp_sq = exp((-x^2/2))
- Parameters
w (np.array) – Array to apply contrast function to.
der (boolean) – Whether to apply derivative (or base version).
- Returns
Array with contrast function applied, same shape as w.
- Return type
np.array
Examples
>>> w = np.array([1, 2, 3, 800]) >>> exp_sq(w, der=False) array([0.60653066, 0.13533528, 0.011109, 0.])
- emgdecompy.contrast.apply_contrast(w, fun=skew, der=False)[source]
Takes first derivitive and applies contrast function to w for Step 2a of fixed point algorithm. Options include functions mentioned in Negro et al. (2016).
- Parameters
fun (str) – Name of contrast function to use.
w (numpy.ndarray) – Matrix to apply contrast function to.
- Returns
Matrix with contrast function applied.
- Return type
numpy.ndarray
Examples
>>> w = np.array([1, 2, 3]) >>> fun = skew >>> apply_contrast(w, fun, True) array([1, 4, 9])
>>> w = np.array([0.01, 0.1, 1, 10, 100, 1000]) >>> fun = log_cosh >>> apply_contrast(w, fun) array([4.99991667e-05, 4.99168882e-03, 4.33780830e-01, 9.30685282e+00, 9.93068528e+01, 9.99300000e+02])