
    hv              	          S r SSKrSSKJr  SSKrSSKJrJrJ	r	  S r
S rS$S jrS%S jrS%S	 jrS
 r   S&S jr S'S jr\R$                  R'                  SSSS9  \R$                    S(S j5       r\R$                    S(S j5       rSr\R.                  " \S5      r\R2                  " S)SS0\R$                  R4                  D6\l         \R.                  " \S5      r\R2                  " S)SS0\R$                  R4                  D6\l         \R.                  " \S5      r\R2                  " S)SS0\R$                  R4                  D6\l         \R.                  " \S5      r\R2                  " S)SS0\R$                  R4                  D6\l         \R$                     S*S j5       r\R$                  SS\\
SSS S4S! j5       r " S" S#5      r g)+a  
Numerical Python functions written for compatibility with MATLAB
commands with the same names. Most numerical Python functions can be found in
the `NumPy`_ and `SciPy`_ libraries. What remains here is code for performing
spectral computations and kernel density estimations.

.. _NumPy: https://numpy.org
.. _SciPy: https://www.scipy.org

Spectral functions
------------------

`cohere`
    Coherence (normalized cross spectral density)

`csd`
    Cross spectral density using Welch's average periodogram

`detrend`
    Remove the mean or best fit line from an array

`psd`
    Power spectral density using Welch's average periodogram

`specgram`
    Spectrogram (spectrum over segments of time)

`complex_spectrum`
    Return the complex-valued frequency spectrum of a signal

`magnitude_spectrum`
    Return the magnitude of the frequency spectrum of a signal

`angle_spectrum`
    Return the angle (wrapped phase) of the frequency spectrum of a signal

`phase_spectrum`
    Return the phase (unwrapped angle) of the frequency spectrum of a signal

`detrend_mean`
    Remove the mean from a line.

`detrend_linear`
    Remove the best fit line from a line.

`detrend_none`
    Return the original line.
    N)Number)_api
_docstringcbookc                 F    [         R                  " [        U 5      5      U -  $ )zw
Return *x* times the Hanning (or Hann) window of len(*x*).

See Also
--------
window_none : Another window algorithm.
)nphanninglenxs    A/var/www/html/env/lib/python3.13/site-packages/matplotlib/mlab.pywindow_hanningr   :   s     ::c!fa    c                     U $ )zf
No window function; simply return *x*.

See Also
--------
window_hanning : Another window algorithm.
 r   s    r   window_noner   E   s	     Hr   c                    Ub  US;   a  [        U [        US9$ US:X  a  [        U [        US9$ US:X  a  [        U [        US9$ [	        U5      (       at  [
        R                  " U 5      n Ub"  US-   U R                  :  a  [        SU S35      eUc  U R                  S:X  d  U(       d  U R                  S:X  a  U" U 5      $  U" XS	9$ [        SU< S35      e! [         a    [
        R                  " XU S
9s $ f = f)a   
Return *x* with its trend removed.

Parameters
----------
x : array or sequence
    Array or sequence containing the data.

key : {'default', 'constant', 'mean', 'linear', 'none'} or function
    The detrending algorithm to use. 'default', 'mean', and 'constant' are
    the same as `detrend_mean`. 'linear' is the same as `detrend_linear`.
    'none' is the same as `detrend_none`. The default is 'mean'. See the
    corresponding functions for more details regarding the algorithms. Can
    also be a function that carries out the detrend operation.

axis : int
    The axis along which to do the detrending.

See Also
--------
detrend_mean : Implementation of the 'mean' algorithm.
detrend_linear : Implementation of the 'linear' algorithm.
detrend_none : Implementation of the 'none' algorithm.
)constantmeandefault)keyaxislinearnone   zaxis(=z) out of boundsr   r   )r   arrzUnknown value for key: zH, must be one of: 'default', 'constant', 'mean', 'linear', or a function)detrenddetrend_meandetrend_lineardetrend_nonecallabler   asarrayndim
ValueError	TypeErrorapply_along_axis)r   r   r   s      r   r   r   P   s   2 {c<<ql66	qn488	ql66	#JJqMq166 1vdV?;<<LQVVq[$166Q;q6M	>q$$ %cW -: ;< 	<  	>&&s1==	>s   C C98C9c                     [         R                  " U 5      n Ub!  US-   U R                  :  a  [        SU-  5      eX R	                  USS9-
  $ )a  
Return *x* minus the mean(*x*).

Parameters
----------
x : array or sequence
    Array or sequence containing the data
    Can have any dimensionality

axis : int
    The axis along which to take the mean.  See `numpy.mean` for a
    description of this argument.

See Also
--------
detrend_linear : Another detrend algorithm.
detrend_none : Another detrend algorithm.
detrend : A wrapper around all the detrend algorithms.
r   zaxis(=%s) out of boundsT)keepdims)r   r#   r$   r%   r   r   r   s     r   r   r      sL    ( 	

1ADFQVVO2T9::vvdTv***r   c                     U $ )af  
Return *x*: no detrending.

Parameters
----------
x : any object
    An object containing the data

axis : int
    This parameter is ignored.
    It is included for compatibility with detrend_mean

See Also
--------
detrend_mean : Another detrend algorithm.
detrend_linear : Another detrend algorithm.
detrend : A wrapper around all the detrend algorithms.
r   r*   s     r   r!   r!      s	    & Hr   c                    [         R                  " U 5      n U R                  S:  a  [        S5      eU R                  (       d  [         R                  " SU R
                  S9$ [         R                  " U R                  [        S9n[         R                  " XSS9nUS   US   -  nU R                  5       X1R                  5       -  -
  nXU-  U-   -
  $ )a6  
Return *x* minus best fit line; 'linear' detrending.

Parameters
----------
y : 0-D or 1-D array or sequence
    Array or sequence containing the data

See Also
--------
detrend_mean : Another detrend algorithm.
detrend_none : Another detrend algorithm.
detrend : A wrapper around all the detrend algorithms.
r   zy cannot have ndim > 1g        )dtype)bias)r   r   )r   r   )r   r#   r$   r%   arrayr-   arangesizefloatcovr   )yr   Cbas        r   r    r       s      	

1Avvz122 66xx!''**
		!&&&A
q!A	$$A	1VVX:A!a=r   c                 	   Uc  SnOXL nUc  SnUc  SnUc  [         nUc  [        nUc  SnXb:  a  [        S5      eU
b  U
S:X  a  Sn
[        R                  " / S	QU
S
9  U(       d  U
S:w  a  [        S5      e[
        R                  " U 5      n U(       d  [
        R                  " U5      nUb  US:X  a   [
        R                  " U 5      (       a  SnOSn[        R                  " / SQUS9  [        U 5      U:  a%  [        U 5      n[
        R                  " X5      n SXS& U(       d4  [        U5      U:  a%  [        U5      n[
        R                  " X5      nSXS& Uc  UnU
S:w  a  Sn	OU	c  Sn	US:X  a   UnUS-  (       a  US-
  S-  S-   nOUS-  nSnO#US:X  a  US-  (       a	  US-   S-  nOUS-  S-   nSn[
        R                  " U5      (       d&  U" [
        R                  " X R                  5      5      n[        U5      U:w  a  [        S5      e[
        R                  R                  R                  XSS9SSX&-
  2   R                   n[#        UUSS9nUUR%                  S5      -  n[
        R&                  R'                  UUSS9SW2SS24   n[
        R&                  R)                  USU-  5      SU nU(       d  [
        R                  R                  R                  XSS9SSX&-
  2   R                   n[#        UUSS9nUUR%                  S5      -  n[
        R&                  R'                  UUSS9SU2SS24   n[
        R*                  " U5      U-  nOU
S:X  a  [
        R*                  " U5      U-  nOjU
S:X  a(  [
        R,                  " U5      UR/                  5       -  nO<U
S:X  d  U
S:X  a  [
        R0                  " U5      nOU
S:X  a  UUR/                  5       -  nU
S:X  ak  US-  (       d  [3        SSS5      nO[3        SSS5      nUU==   W-  ss'   U	(       a  UU-  nUUS-  R/                  5       -  nOUUR/                  5       S-  -  n[
        R4                  " US-  [        U 5      US-  -
  S-   X&-
  5      U-  nUS:X  a/  [
        R6                  " UW* SS9n[
        R6                  " UU* SS9nOUS-  (       d  US==   S-  ss'   U
S:X  a  [
        R8                  " USS9nUUU4$ )z
Private helper implementing the common parts between the psd, csd,
spectrogram and complex, magnitude, angle, and phase spectrums.
NT   r      znoverlap must be less than NFFTr   psd)r   r;   complex	magnitudeanglephasemodez*x and y must be equal if mode is not 'psd'twosidedonesided)r   rC   rB   )sidesFr   g      ?       @z7The window length must match the data's first dimensionr   )r   )nr   r=   r>   r?   r<   rF   )r!   r   r%   r   check_in_listr   r#   iscomplexobjr
   resizeiterableonesr-   libstride_trickssliding_window_viewTr   reshapefftfftfreqconjabssumr>   slicer0   rollunwrap)r   r4   NFFTFsdetrend_funcwindownoverlappad_torD   scale_by_freqrA   	same_datarG   numFreqs
freqcenterscaling_factorresultfreqsresultYslcts                        r   _spectral_helperrj      s    	y	
 F		z#~ |:;;|ty(D EFF 	

1AJJqM}*??1EE:%H 1v}FIIa"Q$FIIa"~u}		 
A: 1*q1,JJ	*	A:
QHqy1}H;;vgg./
6{dEG 	G VV!!55	a 6 *4?*,,-A V\2FfnnW--FVVZZ&qZ1)8)Q,?FFFNN61R4((3E&&&&::! ; .t.001 	'<a8FNN733&&**WQ*7		1E7*	6)		&**,.	DGO&!		&**,u} ax2t$C 4&Cs~%
 bLF vqyoo''F fjjlAo%F
		$q&#a&46/A-t?BA

{3*15aZb	R	 w6*5!r   c                    [         R                  " / SQU S9  Uc  [        U5      n[        US[        U5      U[        USUUSU S9u  pgnU S:w  a  UR
                  nUR                  S:X  a  UR                  S	   S	:X  a	  USS2S4   nXg4$ )
zi
Private helper implementing the commonality between the complex, magnitude,
angle, and phase spectrums.
)r<   r=   r>   r?   r@   Nr   Fr   r4   rZ   r[   r\   r]   r^   r_   rD   r`   rA   r<   r9   r   )r   rH   r
   rj   r!   realr$   shape)	rA   r   r[   r]   r_   rD   specrf   _s	            r   _single_spectrum_helperrq   x  s     	AM~Q%TA23?/0,149+/1ND yyyyyA~$**Q-1,AqDz;r   aL  Fs : float, default: 2
    The sampling frequency (samples per time unit).  It is used to calculate
    the Fourier frequencies, *freqs*, in cycles per time unit.

window : callable or ndarray, default: `.window_hanning`
    A function or a vector of length *NFFT*.  To create window vectors see
    `.window_hanning`, `.window_none`, `numpy.blackman`, `numpy.hamming`,
    `numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc.  If a
    function is passed as the argument, it must take a data segment as an
    argument and return the windowed version of the segment.

sides : {'default', 'onesided', 'twosided'}, optional
    Which sides of the spectrum to return. 'default' is one-sided for real
    data and two-sided for complex data. 'onesided' forces the return of a
    one-sided spectrum, while 'twosided' forces two-sided.a  pad_to : int, optional
    The number of points to which the data segment is padded when performing
    the FFT.  While not increasing the actual resolution of the spectrum (the
    minimum distance between resolvable peaks), this can give more points in
    the plot, allowing for more detail. This corresponds to the *n* parameter
    in the call to `~numpy.fft.fft`.  The default is None, which sets *pad_to*
    equal to the length of the input signal (i.e. no padding).af  pad_to : int, optional
    The number of points to which the data segment is padded when performing
    the FFT.  This can be different from *NFFT*, which specifies the number
    of data points used.  While not increasing the actual resolution of the
    spectrum (the minimum distance between resolvable peaks), this can give
    more points in the plot, allowing for more detail. This corresponds to
    the *n* parameter in the call to `~numpy.fft.fft`. The default is None,
    which sets *pad_to* equal to *NFFT*

NFFT : int, default: 256
    The number of data points used in each block for the FFT.  A power 2 is
    most efficient.  This should *NOT* be used to get zero padding, or the
    scaling of the result will be incorrect; use *pad_to* for this instead.

detrend : {'none', 'mean', 'linear'} or callable, default: 'none'
    The function applied to each segment before fft-ing, designed to remove
    the mean or linear trend.  Unlike in MATLAB, where the *detrend* parameter
    is a vector, in Matplotlib it is a function.  The :mod:`~matplotlib.mlab`
    module defines `.detrend_none`, `.detrend_mean`, and `.detrend_linear`,
    but you can use a custom function as well.  You can also use a string to
    choose one of the functions: 'none' calls `.detrend_none`. 'mean' calls
    `.detrend_mean`. 'linear' calls `.detrend_linear`.

scale_by_freq : bool, default: True
    Whether the resulting density values should be scaled by the scaling
    frequency, which gives density in units of 1/Hz.  This allows for
    integration over the returned frequency values.  The default is True for
    MATLAB compatibility.)SpectralSingle_SpectrumPSDc	                 @    [        U SXUXEUXxS9
u  pU	R                  U
4$ )a  
Compute the power spectral density.

The power spectral density :math:`P_{xx}` by Welch's average
periodogram method.  The vector *x* is divided into *NFFT* length
segments.  Each segment is detrended by function *detrend* and
windowed by function *window*.  *noverlap* gives the length of
the overlap between segments.  The :math:`|\mathrm{fft}(i)|^2`
of each segment :math:`i` are averaged to compute :math:`P_{xx}`.

If len(*x*) < *NFFT*, it will be zero padded to *NFFT*.

Parameters
----------
x : 1-D array or sequence
    Array or sequence containing the data

%(Spectral)s

%(PSD)s

noverlap : int, default: 0 (no overlap)
    The number of points of overlap between segments.

Returns
-------
Pxx : 1-D array
    The values for the power spectrum :math:`P_{xx}` (real valued)

freqs : 1-D array
    The frequencies corresponding to the elements in *Pxx*

References
----------
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John
Wiley & Sons (1986)

See Also
--------
specgram
    `specgram` differs in the default overlap; in not returning the mean of
    the segment periodograms; and in returning the times of the segments.

magnitude_spectrum : returns the magnitude spectrum.

csd : returns the spectral density between two signals.
N)
r   r4   rZ   r[   r   r]   r^   r_   rD   r`   )csdrm   )r   rZ   r[   r   r]   r^   r_   rD   r`   Pxxrf   s              r   r;   r;     s1    d qDtG"f ?JC 88U?r   c
                     Uc  Sn[        XX#XEXgXSS9u  pnU
R                  S:X  a.  U
R                  S   S:  a  U
R                  SS9n
X4$ U
SS2S4   n
X4$ )	a  
Compute the cross-spectral density.

The cross spectral density :math:`P_{xy}` by Welch's average
periodogram method.  The vectors *x* and *y* are divided into
*NFFT* length segments.  Each segment is detrended by function
*detrend* and windowed by function *window*.  *noverlap* gives
the length of the overlap between segments.  The product of
the direct FFTs of *x* and *y* are averaged over each segment
to compute :math:`P_{xy}`, with a scaling to correct for power
loss due to windowing.

If len(*x*) < *NFFT* or len(*y*) < *NFFT*, they will be zero
padded to *NFFT*.

Parameters
----------
x, y : 1-D arrays or sequences
    Arrays or sequences containing the data

%(Spectral)s

%(PSD)s

noverlap : int, default: 0 (no overlap)
    The number of points of overlap between segments.

Returns
-------
Pxy : 1-D array
    The values for the cross spectrum :math:`P_{xy}` before scaling (real
    valued)

freqs : 1-D array
    The frequencies corresponding to the elements in *Pxy*

References
----------
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John
Wiley & Sons (1986)

See Also
--------
psd : equivalent to setting ``y = x``.
Nr:   r;   rl   r9   r   r   r   )rj   r$   rn   r   )r   r4   rZ   r[   r   r]   r^   r_   rD   r`   Pxyrf   rp   s                r   rv   rv     s{    ` |$qD29.6+0*/	1MC xx1}99Q<!((("C : ad)C:r   a9  Compute the {quantity} of *x*.
Data is padded to a length of *pad_to* and the windowing function *window* is
applied to the signal.

Parameters
----------
x : 1-D array or sequence
    Array or sequence containing the data

{Spectral}

{Single_Spectrum}

Returns
-------
spectrum : 1-D array
    The {quantity}.
freqs : 1-D array
    The frequencies corresponding to the elements in *spectrum*.

See Also
--------
psd
    Returns the power spectral density.
complex_spectrum
    Returns the complex-valued frequency spectrum.
magnitude_spectrum
    Returns the absolute value of the `complex_spectrum`.
angle_spectrum
    Returns the angle of the `complex_spectrum`.
phase_spectrum
    Returns the phase (unwrapped angle) of the `complex_spectrum`.
specgram
    Can return the complex spectrum of segments within the signal.
r<   quantityz!complex-valued frequency spectrumr=   z4magnitude (absolute value) of the frequency spectrumr>   z8angle of the frequency spectrum (wrapped phase spectrum)r?   z:phase of the frequency spectrum (unwrapped phase spectrum)c
                     Uc  SnUc  Sn[        U 5      U::  a&  [        R                  " SU S[        U 5       S35        [        U SXX4XVUUU	S9u  pnU	S:w  a  U
R                  n
XU4$ )	aP  
Compute a spectrogram.

Compute and plot a spectrogram of data in *x*.  Data are split into
*NFFT* length segments and the spectrum of each section is
computed.  The windowing function *window* is applied to each
segment, and the amount of overlap of each segment is
specified with *noverlap*.

Parameters
----------
x : array-like
    1-D array or sequence.

%(Spectral)s

%(PSD)s

noverlap : int, default: 128
    The number of points of overlap between blocks.
mode : str, default: 'psd'
    What sort of spectrum to use:
        'psd'
            Returns the power spectral density.
        'complex'
            Returns the complex-valued frequency spectrum.
        'magnitude'
            Returns the magnitude spectrum.
        'angle'
            Returns the phase spectrum without unwrapping.
        'phase'
            Returns the phase spectrum with unwrapping.

Returns
-------
spectrum : array-like
    2D array, columns are the periodograms of successive segments.

freqs : array-like
    1-D array, frequencies corresponding to the rows in *spectrum*.

t : array-like
    1-D array, the times corresponding to midpoints of segments
    (i.e the columns in *spectrum*).

See Also
--------
psd : differs in the overlap and in the return values.
complex_spectrum : similar, but with complex valued frequencies.
magnitude_spectrum : similar single segment when *mode* is 'magnitude'.
angle_spectrum : similar to single segment when *mode* is 'angle'.
phase_spectrum : similar to single segment when *mode* is 'phase'.

Notes
-----
*detrend* and *scale_by_freq* only apply when *mode* is set to 'psd'.

N   r:   z6Only one segment is calculated since parameter NFFT (=z) >= signal length (=z).rl   r<   )r
   r   warn_externalrj   rm   )r   rZ   r[   r   r]   r^   r_   rD   r`   rA   ro   rf   ri   s                r   specgramr~   }  s    | |
1v~ %%)F*?AxrK 	L &T3:/7,14A+/1ND yyy>r   r:   r9   r   c
                     [        U 5      SU-  :  a  [        S5      e[        XX4XVXxU	5	      u  p[        XX4XVXxU	5	      u  p[        XX#XEXgUU	5
      u  p[        R
                  " U5      S-  X-  -  nX4$ )ai  
The coherence between *x* and *y*.  Coherence is the normalized
cross spectral density:

.. math::

    C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}

Parameters
----------
x, y
    Array or sequence containing the data

%(Spectral)s

%(PSD)s

noverlap : int, default: 0 (no overlap)
    The number of points of overlap between segments.

Returns
-------
Cxy : 1-D array
    The coherence vector.
freqs : 1-D array
        The frequencies for the elements in *Cxy*.

See Also
--------
:func:`psd`, :func:`csd` :
    For information about the methods used to compute :math:`P_{xy}`,
    :math:`P_{xx}` and :math:`P_{yy}`.
r9   zvCoherence is calculated by averaging over *NFFT* length segments.  Your signal is too short for your choice of *NFFT*.)r
   r%   r;   rv   r   rU   )r   r4   rZ   r[   r   r]   r^   r_   rD   r`   rw   fPyyry   Cxys                  r   coherer     s    H 1vDMN 	N "v FC"v FCt(E FC
&&+
ci
(C6Mr   c                   <    \ rS rSrSrS	S jrS rS r\rS r	\	r
Srg)
GaussianKDEi  a  
Representation of a kernel-density estimate using Gaussian kernels.

Parameters
----------
dataset : array-like
    Datapoints to estimate from. In case of univariate data this is a 1-D
    array, otherwise a 2D array with shape (# of dims, # of data).
bw_method : {'scott', 'silverman'} or float or callable, optional
    The method used to calculate the estimator bandwidth.  If a
    float, this will be used directly as `kde.factor`.  If a
    callable, it should take a `GaussianKDE` instance as only
    parameter and return a float. If None (default), 'scott' is used.

Attributes
----------
dataset : ndarray
    The dataset passed to the constructor.
dim : int
    Number of dimensions.
num_dp : int
    Number of datapoints.
factor : float
    The bandwidth factor, obtained from `kde.covariance_factor`, with which
    the covariance matrix is multiplied.
covariance : ndarray
    The covariance matrix of *dataset*, scaled by the calculated bandwidth
    (`kde.factor`).
inv_cov : ndarray
    The inverse of *covariance*.

Methods
-------
kde.evaluate(points) : ndarray
    Evaluate the estimated pdf on a provided set of points.
kde(points) : ndarray
    Same as kde.evaluate(points)
Nc                   ^ ^ [         R                  " U5      T l        [         R                  " T R                  5      R                  S:  d  [        S5      e[         R                  " T R                  5      R                  u  T l        T l        Tc  O[        R                  " TS5      (       a  T R                  T l        O[        R                  " TS5      (       a  T R                  T l        OV[        T[        5      (       a  ST l        U4S jT l        O.[#        T5      (       a  TT l        U 4S jT l        O[        S5      eT R                  5       T l        ['        T S	5      (       dg  [         R                  " [         R(                  " T R                  SS
S95      T l        [         R,                  R/                  T R*                  5      T l        T R*                  T R$                  S-  -  T l        T R0                  T R$                  S-  -  T l        [         R6                  " [         R,                  R9                  S[         R:                  -  T R2                  -  5      5      T R                  -  T l        g )Nr   z.`dataset` input should have multiple elements.scott	silvermanzuse constantc                     > T $ Nr   )	bw_methods   r   <lambda>&GaussianKDE.__init__.<locals>.<lambda><  s    Yr   c                  &   > T R                  T 5      $ r   )
_bw_methodselfs   r   r   r   ?  s    T__T-Br   zB`bw_method` should be 'scott', 'silverman', a scalar or a callable_data_inv_covF)rowvarr.   r9   )r   
atleast_2ddatasetr/   r1   r%   rn   dimnum_dpr   
_str_equalscotts_factorcovariance_factorsilverman_factor
isinstancer   r   r"   factorhasattrr3   data_covariancelinalginvdata_inv_cov
covarianceinv_covsqrtdetpinorm_factor)r   r   r   s   ` `r   __init__GaussianKDE.__init__-  s   }}W-xx%**Q.MNN " 6 < <$+i11%)%7%7D"i55%)%:%:D"	6**,DO%6D"i  'DO%BD" 4 5 5 ,,.t_--#%==LL $!D 
 !#		d.B.B CD..1AA((4;;!+;;GGBIIMM!bee)doo2M$NO"kk*r   c                 d    [         R                  " U R                  SU R                  S-   -  5      $ )N         r   powerr   r   r   s    r   r   GaussianKDE.scotts_factorV  s$    xxSDHHqL%9::r   c                     [         R                  " U R                  U R                  S-   -  S-  SU R                  S-   -  5      $ )NrE   g      @r   r   r   r   s    r   r   GaussianKDE.silverman_factorY  s=    xxKK488c>*S0#A2FH 	Hr   c                    [         R                  " U5      n[         R                  " U5      R                  u  p#X R                  :w  a  [        SU SU R                   35      e[         R                  " U5      nX0R                  :  a  [        U R                  5       H}  nU R                  SS2U[         R                  4   U-
  n[         R                  " U R                  U5      n[         R                  " Xg-  SS9S-  nU[         R                  " U* 5      -   nM     O[        U5       H  nU R                  USS2U[         R                  4   -
  n[         R                  " U R                  U5      n[         R                  " Xg-  SS9S-  n[         R                  " [         R                  " U* 5      SS9XE'   M     X@R                  -  nU$ )a  
Evaluate the estimated pdf on a set of points.

Parameters
----------
points : (# of dimensions, # of points)-array
    Alternatively, a (# of dimensions,) vector can be passed in and
    treated as a single point.

Returns
-------
(# of points,)-array
    The values at each point.

Raises
------
ValueError : if the dimensionality of the input points is different
             than the dimensionality of the KDE.

zpoints have dimension z, dataset has dimension Nr   r   rE   )r   r   r/   rn   r   r%   zerosr   ranger   newaxisdotr   rV   expr   )	r   pointsr   num_mre   idifftdiffenergys	            r   evaluateGaussianKDE.evaluate`  sk   * v&XXf%++
((?5cU ;**.((5 6 6 %KK4;;'||Aq"**$45>t||T215;"&&&/1	 ( 5\||fQ2::-=&>>t||T215;FF2666'?;		 " ***r   )r   r   r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   __call____static_attributes__r   r   r   r   r     s.    %T'+R;H
 &/b Hr   r   )NNr   )
NNNNNNNNNN)NNNN)NNNNNNNNr   )	NNNNNNNNN)!r   	functoolsnumbersr   numpyr   
matplotlibr   r   r   r   r   r   r   r!   r    rj   rq   interpdregisterr;   rv   _single_spectrum_docspartialcomplex_spectrumformatparamsmagnitude_spectrumangle_spectrumphase_spectrumr~   r   r   r   r   r   <module>r      sD  /b    . . .<b+8,D BF8<:>`H ;?6     >"B	7  7t 48>B4 4n 7;>B< <~# L $$%<iH 077 !0!!   &&'>L 299 !C!!   ""#:GD.55 !G!!  ""#:GD.55 !I!! 
 9=CGO Od and)4. .bO Or   