watex.utils.exmath.smooth1d#
- watex.utils.exmath.smooth1d(ar, /, drop_outliers=True, ma=True, absolute=False, interpolate=False, view=False, x=None, xlabel=None, ylabel=None, fig_size=(10, 5))[source]#
Smooth one-dimensional array.
- Parameters
ar (ArrayLike 1d) – Array of one-dimensional
drop_outliers (bool, default=True) – Remove the outliers in the data before smoothing
ma (bool, default=True,) – Use the moving average for smoothing array value. This seems more realistic.
interpolate (bool, default=False) –
Interpolate value to fit the original data size after NaN filling.
New in version 0.2.8.
absolute (bool, default=False,) – keep postive the extrapolated scaled values. Indeed, when scaling data, negative value can be appear due to the polyfit function. to absolute this value, set
absolute=True. Note that converting to values to positive must be considered as the last option when values in the array must be positive.view (bool, default =False) – Display curves
x (ArrayLike, optional) – Abscissa array for visualization. If given, it must be consistent with the given array ar. Raises error otherwise.
xlabel (str, optional) – Label of x
ylabel (str, optional) – label of y
fig_size (tuple , default=(10, 5)) – Matplotlib figure size
- Returns
yc – Smoothed array value.
- Return type
ArrayLike
Examples
>>> import numpy as np >>> from watex.utils.exmath import smooth1d >>> # add Guassian Noise >>> np.random.seed (42) >>> ar = np.random.randn (20 ) * 20 + np.random.normal ( 20 ) >>> ar [:7 ] array([6.42891445e+00, 3.75072493e-02, 1.82905357e+01, 2.92957265e+01, 6.20589038e+01, 2.26399535e+01, 1.12596434e+01]) >>> arc = smooth1d (ar, view =True , ma =False ) >>> arc [:7 ] array([12.08603102, 15.29819907, 18.017749 , 20.27968322, 22.11900412, 23.5707141 , 24.66981557]) >>> arc = smooth1d (ar, view =True )# ma=True by default array([ 5.0071604 , 5.90839339, 9.6264018 , 13.94679804, 17.67369252, 20.34922943, 22.00836725])