@@ -1769,3 +1769,119 @@ def signal_cross_join(signal1=None,
17691769 names = ('matrix_index' , 'matrix_profile' )
17701770
17711771 return utils .ReturnTuple (args , names )
1772+
1773+
1774+ def mean_waves (data = None , size = None , step = None ):
1775+ """Extract mean samples from a data set.
1776+
1777+ Parameters
1778+ ----------
1779+ data : array
1780+ An m by n array of m data samples in an n-dimensional space.
1781+ size : int
1782+ Number of samples to use for each mean sample.
1783+ step : int, optional
1784+ Number of samples to jump, controlling overlap; default is equal to
1785+ `size` (no overlap).
1786+
1787+ Returns
1788+ -------
1789+ waves : array
1790+ An k by n array of mean samples.
1791+
1792+ Notes
1793+ -----
1794+ * Discards trailing samples if they are not enough to satify the `size`
1795+ parameter.
1796+
1797+ Raises
1798+ ------
1799+ ValueError
1800+ If `step` is an invalid value.
1801+ ValueError
1802+ If there are not enough samples for the given `size`.
1803+
1804+ """
1805+
1806+ # check inputs
1807+ if data is None :
1808+ raise TypeError ("Please specify an input data set." )
1809+
1810+ if size is None :
1811+ raise TypeError ("Please specify the number of samples for the mean." )
1812+
1813+ if step is None :
1814+ step = size
1815+
1816+ if step < 0 :
1817+ raise ValueError ("The step must be a positive integer." )
1818+
1819+ # number of waves
1820+ L = len (data ) - size
1821+ nb = 1 + L // step
1822+ if nb <= 0 :
1823+ raise ValueError ("Not enough samples for the given `size`." )
1824+
1825+ # compute
1826+ waves = [np .mean (data [i :i + size ], axis = 0 ) for i in range (0 , L + 1 , step )]
1827+ waves = np .array (waves )
1828+
1829+ return utils .ReturnTuple ((waves , ), ('waves' , ))
1830+
1831+
1832+ def median_waves (data = None , size = None , step = None ):
1833+ """Extract median samples from a data set.
1834+
1835+ Parameters
1836+ ----------
1837+ data : array
1838+ An m by n array of m data samples in an n-dimensional space.
1839+ size : int
1840+ Number of samples to use for each median sample.
1841+ step : int, optional
1842+ Number of samples to jump, controlling overlap; default is equal to
1843+ `size` (no overlap).
1844+
1845+ Returns
1846+ -------
1847+ waves : array
1848+ An k by n array of median samples.
1849+
1850+ Notes
1851+ -----
1852+ * Discards trailing samples if they are not enough to satify the `size`
1853+ parameter.
1854+
1855+ Raises
1856+ ------
1857+ ValueError
1858+ If `step` is an invalid value.
1859+ ValueError
1860+ If there are not enough samples for the given `size`.
1861+
1862+ """
1863+
1864+ # check inputs
1865+ if data is None :
1866+ raise TypeError ("Please specify an input data set." )
1867+
1868+ if size is None :
1869+ raise TypeError ("Please specify the number of samples for the median." )
1870+
1871+ if step is None :
1872+ step = size
1873+
1874+ if step < 0 :
1875+ raise ValueError ("The step must be a positive integer." )
1876+
1877+ # number of waves
1878+ L = len (data ) - size
1879+ nb = 1 + L // step
1880+ if nb <= 0 :
1881+ raise ValueError ("Not enough samples for the given `size`." )
1882+
1883+ # compute
1884+ waves = [np .median (data [i :i + size ], axis = 0 ) for i in range (0 , L + 1 , step )]
1885+ waves = np .array (waves )
1886+
1887+ return utils .ReturnTuple ((waves , ), ('waves' , ))
0 commit comments