Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- env-llmeval/lib/python3.10/site-packages/scipy/signal/__init__.py +346 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_arraytools.py +264 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_bsplines.py +519 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_max_len_seq.py +139 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_max_len_seq_inner.cpython-310-x86_64-linux-gnu.so +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_short_time_fft.py +1676 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_signaltools.py +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_sosfilt.cpython-310-x86_64-linux-gnu.so +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_spectral_py.py +2101 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/_upfirdn_apply.cpython-310-x86_64-linux-gnu.so +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/signal/ltisys.py +30 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/__init__.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/_plotutils.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/_procrustes.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/_spherical_voronoi.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/ckdtree.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/distance.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__init__.py +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test__plotutils.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test__procrustes.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_distance.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_hausdorff.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_kdtree.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_qhull.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_slerp.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_spherical_voronoi.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/cdist-X1.txt +10 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/cdist-X2.txt +20 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/iris.txt +150 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-boolean-inp.txt +20 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cosine-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-double-inp.txt +20 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-hamming-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-jaccard-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt +1 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt +0 -0
- env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt +0 -0
env-llmeval/lib/python3.10/site-packages/scipy/signal/__init__.py
ADDED
@@ -0,0 +1,346 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
=======================================
|
3 |
+
Signal processing (:mod:`scipy.signal`)
|
4 |
+
=======================================
|
5 |
+
|
6 |
+
Convolution
|
7 |
+
===========
|
8 |
+
|
9 |
+
.. autosummary::
|
10 |
+
:toctree: generated/
|
11 |
+
|
12 |
+
convolve -- N-D convolution.
|
13 |
+
correlate -- N-D correlation.
|
14 |
+
fftconvolve -- N-D convolution using the FFT.
|
15 |
+
oaconvolve -- N-D convolution using the overlap-add method.
|
16 |
+
convolve2d -- 2-D convolution (more options).
|
17 |
+
correlate2d -- 2-D correlation (more options).
|
18 |
+
sepfir2d -- Convolve with a 2-D separable FIR filter.
|
19 |
+
choose_conv_method -- Chooses faster of FFT and direct convolution methods.
|
20 |
+
correlation_lags -- Determines lag indices for 1D cross-correlation.
|
21 |
+
|
22 |
+
B-splines
|
23 |
+
=========
|
24 |
+
|
25 |
+
.. autosummary::
|
26 |
+
:toctree: generated/
|
27 |
+
|
28 |
+
gauss_spline -- Gaussian approximation to the B-spline basis function.
|
29 |
+
cspline1d -- Coefficients for 1-D cubic (3rd order) B-spline.
|
30 |
+
qspline1d -- Coefficients for 1-D quadratic (2nd order) B-spline.
|
31 |
+
cspline2d -- Coefficients for 2-D cubic (3rd order) B-spline.
|
32 |
+
qspline2d -- Coefficients for 2-D quadratic (2nd order) B-spline.
|
33 |
+
cspline1d_eval -- Evaluate a cubic spline at the given points.
|
34 |
+
qspline1d_eval -- Evaluate a quadratic spline at the given points.
|
35 |
+
spline_filter -- Smoothing spline (cubic) filtering of a rank-2 array.
|
36 |
+
|
37 |
+
Filtering
|
38 |
+
=========
|
39 |
+
|
40 |
+
.. autosummary::
|
41 |
+
:toctree: generated/
|
42 |
+
|
43 |
+
order_filter -- N-D order filter.
|
44 |
+
medfilt -- N-D median filter.
|
45 |
+
medfilt2d -- 2-D median filter (faster).
|
46 |
+
wiener -- N-D Wiener filter.
|
47 |
+
|
48 |
+
symiirorder1 -- 2nd-order IIR filter (cascade of first-order systems).
|
49 |
+
symiirorder2 -- 4th-order IIR filter (cascade of second-order systems).
|
50 |
+
lfilter -- 1-D FIR and IIR digital linear filtering.
|
51 |
+
lfiltic -- Construct initial conditions for `lfilter`.
|
52 |
+
lfilter_zi -- Compute an initial state zi for the lfilter function that
|
53 |
+
-- corresponds to the steady state of the step response.
|
54 |
+
filtfilt -- A forward-backward filter.
|
55 |
+
savgol_filter -- Filter a signal using the Savitzky-Golay filter.
|
56 |
+
|
57 |
+
deconvolve -- 1-D deconvolution using lfilter.
|
58 |
+
|
59 |
+
sosfilt -- 1-D IIR digital linear filtering using
|
60 |
+
-- a second-order sections filter representation.
|
61 |
+
sosfilt_zi -- Compute an initial state zi for the sosfilt function that
|
62 |
+
-- corresponds to the steady state of the step response.
|
63 |
+
sosfiltfilt -- A forward-backward filter for second-order sections.
|
64 |
+
hilbert -- Compute 1-D analytic signal, using the Hilbert transform.
|
65 |
+
hilbert2 -- Compute 2-D analytic signal, using the Hilbert transform.
|
66 |
+
|
67 |
+
decimate -- Downsample a signal.
|
68 |
+
detrend -- Remove linear and/or constant trends from data.
|
69 |
+
resample -- Resample using Fourier method.
|
70 |
+
resample_poly -- Resample using polyphase filtering method.
|
71 |
+
upfirdn -- Upsample, apply FIR filter, downsample.
|
72 |
+
|
73 |
+
Filter design
|
74 |
+
=============
|
75 |
+
|
76 |
+
.. autosummary::
|
77 |
+
:toctree: generated/
|
78 |
+
|
79 |
+
bilinear -- Digital filter from an analog filter using
|
80 |
+
-- the bilinear transform.
|
81 |
+
bilinear_zpk -- Digital filter from an analog filter using
|
82 |
+
-- the bilinear transform.
|
83 |
+
findfreqs -- Find array of frequencies for computing filter response.
|
84 |
+
firls -- FIR filter design using least-squares error minimization.
|
85 |
+
firwin -- Windowed FIR filter design, with frequency response
|
86 |
+
-- defined as pass and stop bands.
|
87 |
+
firwin2 -- Windowed FIR filter design, with arbitrary frequency
|
88 |
+
-- response.
|
89 |
+
freqs -- Analog filter frequency response from TF coefficients.
|
90 |
+
freqs_zpk -- Analog filter frequency response from ZPK coefficients.
|
91 |
+
freqz -- Digital filter frequency response from TF coefficients.
|
92 |
+
freqz_zpk -- Digital filter frequency response from ZPK coefficients.
|
93 |
+
sosfreqz -- Digital filter frequency response for SOS format filter.
|
94 |
+
gammatone -- FIR and IIR gammatone filter design.
|
95 |
+
group_delay -- Digital filter group delay.
|
96 |
+
iirdesign -- IIR filter design given bands and gains.
|
97 |
+
iirfilter -- IIR filter design given order and critical frequencies.
|
98 |
+
kaiser_atten -- Compute the attenuation of a Kaiser FIR filter, given
|
99 |
+
-- the number of taps and the transition width at
|
100 |
+
-- discontinuities in the frequency response.
|
101 |
+
kaiser_beta -- Compute the Kaiser parameter beta, given the desired
|
102 |
+
-- FIR filter attenuation.
|
103 |
+
kaiserord -- Design a Kaiser window to limit ripple and width of
|
104 |
+
-- transition region.
|
105 |
+
minimum_phase -- Convert a linear phase FIR filter to minimum phase.
|
106 |
+
savgol_coeffs -- Compute the FIR filter coefficients for a Savitzky-Golay
|
107 |
+
-- filter.
|
108 |
+
remez -- Optimal FIR filter design.
|
109 |
+
|
110 |
+
unique_roots -- Unique roots and their multiplicities.
|
111 |
+
residue -- Partial fraction expansion of b(s) / a(s).
|
112 |
+
residuez -- Partial fraction expansion of b(z) / a(z).
|
113 |
+
invres -- Inverse partial fraction expansion for analog filter.
|
114 |
+
invresz -- Inverse partial fraction expansion for digital filter.
|
115 |
+
BadCoefficients -- Warning on badly conditioned filter coefficients.
|
116 |
+
|
117 |
+
Lower-level filter design functions:
|
118 |
+
|
119 |
+
.. autosummary::
|
120 |
+
:toctree: generated/
|
121 |
+
|
122 |
+
abcd_normalize -- Check state-space matrices and ensure they are rank-2.
|
123 |
+
band_stop_obj -- Band Stop Objective Function for order minimization.
|
124 |
+
besselap -- Return (z,p,k) for analog prototype of Bessel filter.
|
125 |
+
buttap -- Return (z,p,k) for analog prototype of Butterworth filter.
|
126 |
+
cheb1ap -- Return (z,p,k) for type I Chebyshev filter.
|
127 |
+
cheb2ap -- Return (z,p,k) for type II Chebyshev filter.
|
128 |
+
cmplx_sort -- Sort roots based on magnitude.
|
129 |
+
ellipap -- Return (z,p,k) for analog prototype of elliptic filter.
|
130 |
+
lp2bp -- Transform a lowpass filter prototype to a bandpass filter.
|
131 |
+
lp2bp_zpk -- Transform a lowpass filter prototype to a bandpass filter.
|
132 |
+
lp2bs -- Transform a lowpass filter prototype to a bandstop filter.
|
133 |
+
lp2bs_zpk -- Transform a lowpass filter prototype to a bandstop filter.
|
134 |
+
lp2hp -- Transform a lowpass filter prototype to a highpass filter.
|
135 |
+
lp2hp_zpk -- Transform a lowpass filter prototype to a highpass filter.
|
136 |
+
lp2lp -- Transform a lowpass filter prototype to a lowpass filter.
|
137 |
+
lp2lp_zpk -- Transform a lowpass filter prototype to a lowpass filter.
|
138 |
+
normalize -- Normalize polynomial representation of a transfer function.
|
139 |
+
|
140 |
+
|
141 |
+
|
142 |
+
Matlab-style IIR filter design
|
143 |
+
==============================
|
144 |
+
|
145 |
+
.. autosummary::
|
146 |
+
:toctree: generated/
|
147 |
+
|
148 |
+
butter -- Butterworth
|
149 |
+
buttord
|
150 |
+
cheby1 -- Chebyshev Type I
|
151 |
+
cheb1ord
|
152 |
+
cheby2 -- Chebyshev Type II
|
153 |
+
cheb2ord
|
154 |
+
ellip -- Elliptic (Cauer)
|
155 |
+
ellipord
|
156 |
+
bessel -- Bessel (no order selection available -- try butterod)
|
157 |
+
iirnotch -- Design second-order IIR notch digital filter.
|
158 |
+
iirpeak -- Design second-order IIR peak (resonant) digital filter.
|
159 |
+
iircomb -- Design IIR comb filter.
|
160 |
+
|
161 |
+
Continuous-time linear systems
|
162 |
+
==============================
|
163 |
+
|
164 |
+
.. autosummary::
|
165 |
+
:toctree: generated/
|
166 |
+
|
167 |
+
lti -- Continuous-time linear time invariant system base class.
|
168 |
+
StateSpace -- Linear time invariant system in state space form.
|
169 |
+
TransferFunction -- Linear time invariant system in transfer function form.
|
170 |
+
ZerosPolesGain -- Linear time invariant system in zeros, poles, gain form.
|
171 |
+
lsim -- Continuous-time simulation of output to linear system.
|
172 |
+
impulse -- Impulse response of linear, time-invariant (LTI) system.
|
173 |
+
step -- Step response of continuous-time LTI system.
|
174 |
+
freqresp -- Frequency response of a continuous-time LTI system.
|
175 |
+
bode -- Bode magnitude and phase data (continuous-time LTI).
|
176 |
+
|
177 |
+
Discrete-time linear systems
|
178 |
+
============================
|
179 |
+
|
180 |
+
.. autosummary::
|
181 |
+
:toctree: generated/
|
182 |
+
|
183 |
+
dlti -- Discrete-time linear time invariant system base class.
|
184 |
+
StateSpace -- Linear time invariant system in state space form.
|
185 |
+
TransferFunction -- Linear time invariant system in transfer function form.
|
186 |
+
ZerosPolesGain -- Linear time invariant system in zeros, poles, gain form.
|
187 |
+
dlsim -- Simulation of output to a discrete-time linear system.
|
188 |
+
dimpulse -- Impulse response of a discrete-time LTI system.
|
189 |
+
dstep -- Step response of a discrete-time LTI system.
|
190 |
+
dfreqresp -- Frequency response of a discrete-time LTI system.
|
191 |
+
dbode -- Bode magnitude and phase data (discrete-time LTI).
|
192 |
+
|
193 |
+
LTI representations
|
194 |
+
===================
|
195 |
+
|
196 |
+
.. autosummary::
|
197 |
+
:toctree: generated/
|
198 |
+
|
199 |
+
tf2zpk -- Transfer function to zero-pole-gain.
|
200 |
+
tf2sos -- Transfer function to second-order sections.
|
201 |
+
tf2ss -- Transfer function to state-space.
|
202 |
+
zpk2tf -- Zero-pole-gain to transfer function.
|
203 |
+
zpk2sos -- Zero-pole-gain to second-order sections.
|
204 |
+
zpk2ss -- Zero-pole-gain to state-space.
|
205 |
+
ss2tf -- State-pace to transfer function.
|
206 |
+
ss2zpk -- State-space to pole-zero-gain.
|
207 |
+
sos2zpk -- Second-order sections to zero-pole-gain.
|
208 |
+
sos2tf -- Second-order sections to transfer function.
|
209 |
+
cont2discrete -- Continuous-time to discrete-time LTI conversion.
|
210 |
+
place_poles -- Pole placement.
|
211 |
+
|
212 |
+
Waveforms
|
213 |
+
=========
|
214 |
+
|
215 |
+
.. autosummary::
|
216 |
+
:toctree: generated/
|
217 |
+
|
218 |
+
chirp -- Frequency swept cosine signal, with several freq functions.
|
219 |
+
gausspulse -- Gaussian modulated sinusoid.
|
220 |
+
max_len_seq -- Maximum length sequence.
|
221 |
+
sawtooth -- Periodic sawtooth.
|
222 |
+
square -- Square wave.
|
223 |
+
sweep_poly -- Frequency swept cosine signal; freq is arbitrary polynomial.
|
224 |
+
unit_impulse -- Discrete unit impulse.
|
225 |
+
|
226 |
+
Window functions
|
227 |
+
================
|
228 |
+
|
229 |
+
For window functions, see the `scipy.signal.windows` namespace.
|
230 |
+
|
231 |
+
In the `scipy.signal` namespace, there is a convenience function to
|
232 |
+
obtain these windows by name:
|
233 |
+
|
234 |
+
.. autosummary::
|
235 |
+
:toctree: generated/
|
236 |
+
|
237 |
+
get_window -- Return a window of a given length and type.
|
238 |
+
|
239 |
+
Wavelets
|
240 |
+
========
|
241 |
+
|
242 |
+
.. autosummary::
|
243 |
+
:toctree: generated/
|
244 |
+
|
245 |
+
cascade -- Compute scaling function and wavelet from coefficients.
|
246 |
+
daub -- Return low-pass.
|
247 |
+
morlet -- Complex Morlet wavelet.
|
248 |
+
qmf -- Return quadrature mirror filter from low-pass.
|
249 |
+
ricker -- Return ricker wavelet.
|
250 |
+
morlet2 -- Return Morlet wavelet, compatible with cwt.
|
251 |
+
cwt -- Perform continuous wavelet transform.
|
252 |
+
|
253 |
+
Peak finding
|
254 |
+
============
|
255 |
+
|
256 |
+
.. autosummary::
|
257 |
+
:toctree: generated/
|
258 |
+
|
259 |
+
argrelmin -- Calculate the relative minima of data.
|
260 |
+
argrelmax -- Calculate the relative maxima of data.
|
261 |
+
argrelextrema -- Calculate the relative extrema of data.
|
262 |
+
find_peaks -- Find a subset of peaks inside a signal.
|
263 |
+
find_peaks_cwt -- Find peaks in a 1-D array with wavelet transformation.
|
264 |
+
peak_prominences -- Calculate the prominence of each peak in a signal.
|
265 |
+
peak_widths -- Calculate the width of each peak in a signal.
|
266 |
+
|
267 |
+
Spectral analysis
|
268 |
+
=================
|
269 |
+
|
270 |
+
.. autosummary::
|
271 |
+
:toctree: generated/
|
272 |
+
|
273 |
+
periodogram -- Compute a (modified) periodogram.
|
274 |
+
welch -- Compute a periodogram using Welch's method.
|
275 |
+
csd -- Compute the cross spectral density, using Welch's method.
|
276 |
+
coherence -- Compute the magnitude squared coherence, using Welch's method.
|
277 |
+
spectrogram -- Compute the spectrogram (legacy).
|
278 |
+
lombscargle -- Computes the Lomb-Scargle periodogram.
|
279 |
+
vectorstrength -- Computes the vector strength.
|
280 |
+
ShortTimeFFT -- Interface for calculating the \
|
281 |
+
:ref:`Short Time Fourier Transform <tutorial_stft>` and \
|
282 |
+
its inverse.
|
283 |
+
stft -- Compute the Short Time Fourier Transform (legacy).
|
284 |
+
istft -- Compute the Inverse Short Time Fourier Transform (legacy).
|
285 |
+
check_COLA -- Check the COLA constraint for iSTFT reconstruction.
|
286 |
+
check_NOLA -- Check the NOLA constraint for iSTFT reconstruction.
|
287 |
+
|
288 |
+
Chirp Z-transform and Zoom FFT
|
289 |
+
============================================
|
290 |
+
|
291 |
+
.. autosummary::
|
292 |
+
:toctree: generated/
|
293 |
+
|
294 |
+
czt - Chirp z-transform convenience function
|
295 |
+
zoom_fft - Zoom FFT convenience function
|
296 |
+
CZT - Chirp z-transform function generator
|
297 |
+
ZoomFFT - Zoom FFT function generator
|
298 |
+
czt_points - Output the z-plane points sampled by a chirp z-transform
|
299 |
+
|
300 |
+
The functions are simpler to use than the classes, but are less efficient when
|
301 |
+
using the same transform on many arrays of the same length, since they
|
302 |
+
repeatedly generate the same chirp signal with every call. In these cases,
|
303 |
+
use the classes to create a reusable function instead.
|
304 |
+
|
305 |
+
"""
|
306 |
+
|
307 |
+
from . import _sigtools, windows
|
308 |
+
from ._waveforms import *
|
309 |
+
from ._max_len_seq import max_len_seq
|
310 |
+
from ._upfirdn import upfirdn
|
311 |
+
|
312 |
+
from ._spline import (
|
313 |
+
cspline2d,
|
314 |
+
qspline2d,
|
315 |
+
sepfir2d,
|
316 |
+
symiirorder1,
|
317 |
+
symiirorder2,
|
318 |
+
)
|
319 |
+
|
320 |
+
from ._bsplines import *
|
321 |
+
from ._filter_design import *
|
322 |
+
from ._fir_filter_design import *
|
323 |
+
from ._ltisys import *
|
324 |
+
from ._lti_conversion import *
|
325 |
+
from ._signaltools import *
|
326 |
+
from ._savitzky_golay import savgol_coeffs, savgol_filter
|
327 |
+
from ._spectral_py import *
|
328 |
+
from ._short_time_fft import *
|
329 |
+
from ._wavelets import *
|
330 |
+
from ._peak_finding import *
|
331 |
+
from ._czt import *
|
332 |
+
from .windows import get_window # keep this one in signal namespace
|
333 |
+
|
334 |
+
# Deprecated namespaces, to be removed in v2.0.0
|
335 |
+
from . import (
|
336 |
+
bsplines, filter_design, fir_filter_design, lti_conversion, ltisys,
|
337 |
+
spectral, signaltools, waveforms, wavelets, spline
|
338 |
+
)
|
339 |
+
|
340 |
+
__all__ = [
|
341 |
+
s for s in dir() if not s.startswith("_")
|
342 |
+
]
|
343 |
+
|
344 |
+
from scipy._lib._testutils import PytestTester
|
345 |
+
test = PytestTester(__name__)
|
346 |
+
del PytestTester
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_arraytools.py
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Functions for acting on a axis of an array.
|
3 |
+
"""
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
|
7 |
+
def axis_slice(a, start=None, stop=None, step=None, axis=-1):
|
8 |
+
"""Take a slice along axis 'axis' from 'a'.
|
9 |
+
|
10 |
+
Parameters
|
11 |
+
----------
|
12 |
+
a : numpy.ndarray
|
13 |
+
The array to be sliced.
|
14 |
+
start, stop, step : int or None
|
15 |
+
The slice parameters.
|
16 |
+
axis : int, optional
|
17 |
+
The axis of `a` to be sliced.
|
18 |
+
|
19 |
+
Examples
|
20 |
+
--------
|
21 |
+
>>> import numpy as np
|
22 |
+
>>> from scipy.signal._arraytools import axis_slice
|
23 |
+
>>> a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
|
24 |
+
>>> axis_slice(a, start=0, stop=1, axis=1)
|
25 |
+
array([[1],
|
26 |
+
[4],
|
27 |
+
[7]])
|
28 |
+
>>> axis_slice(a, start=1, axis=0)
|
29 |
+
array([[4, 5, 6],
|
30 |
+
[7, 8, 9]])
|
31 |
+
|
32 |
+
Notes
|
33 |
+
-----
|
34 |
+
The keyword arguments start, stop and step are used by calling
|
35 |
+
slice(start, stop, step). This implies axis_slice() does not
|
36 |
+
handle its arguments the exactly the same as indexing. To select
|
37 |
+
a single index k, for example, use
|
38 |
+
axis_slice(a, start=k, stop=k+1)
|
39 |
+
In this case, the length of the axis 'axis' in the result will
|
40 |
+
be 1; the trivial dimension is not removed. (Use numpy.squeeze()
|
41 |
+
to remove trivial axes.)
|
42 |
+
"""
|
43 |
+
a_slice = [slice(None)] * a.ndim
|
44 |
+
a_slice[axis] = slice(start, stop, step)
|
45 |
+
b = a[tuple(a_slice)]
|
46 |
+
return b
|
47 |
+
|
48 |
+
|
49 |
+
def axis_reverse(a, axis=-1):
|
50 |
+
"""Reverse the 1-D slices of `a` along axis `axis`.
|
51 |
+
|
52 |
+
Returns axis_slice(a, step=-1, axis=axis).
|
53 |
+
"""
|
54 |
+
return axis_slice(a, step=-1, axis=axis)
|
55 |
+
|
56 |
+
|
57 |
+
def odd_ext(x, n, axis=-1):
|
58 |
+
"""
|
59 |
+
Odd extension at the boundaries of an array
|
60 |
+
|
61 |
+
Generate a new ndarray by making an odd extension of `x` along an axis.
|
62 |
+
|
63 |
+
Parameters
|
64 |
+
----------
|
65 |
+
x : ndarray
|
66 |
+
The array to be extended.
|
67 |
+
n : int
|
68 |
+
The number of elements by which to extend `x` at each end of the axis.
|
69 |
+
axis : int, optional
|
70 |
+
The axis along which to extend `x`. Default is -1.
|
71 |
+
|
72 |
+
Examples
|
73 |
+
--------
|
74 |
+
>>> import numpy as np
|
75 |
+
>>> from scipy.signal._arraytools import odd_ext
|
76 |
+
>>> a = np.array([[1, 2, 3, 4, 5], [0, 1, 4, 9, 16]])
|
77 |
+
>>> odd_ext(a, 2)
|
78 |
+
array([[-1, 0, 1, 2, 3, 4, 5, 6, 7],
|
79 |
+
[-4, -1, 0, 1, 4, 9, 16, 23, 28]])
|
80 |
+
|
81 |
+
Odd extension is a "180 degree rotation" at the endpoints of the original
|
82 |
+
array:
|
83 |
+
|
84 |
+
>>> t = np.linspace(0, 1.5, 100)
|
85 |
+
>>> a = 0.9 * np.sin(2 * np.pi * t**2)
|
86 |
+
>>> b = odd_ext(a, 40)
|
87 |
+
>>> import matplotlib.pyplot as plt
|
88 |
+
>>> plt.plot(np.arange(-40, 140), b, 'b', lw=1, label='odd extension')
|
89 |
+
>>> plt.plot(np.arange(100), a, 'r', lw=2, label='original')
|
90 |
+
>>> plt.legend(loc='best')
|
91 |
+
>>> plt.show()
|
92 |
+
"""
|
93 |
+
if n < 1:
|
94 |
+
return x
|
95 |
+
if n > x.shape[axis] - 1:
|
96 |
+
raise ValueError(("The extension length n (%d) is too big. " +
|
97 |
+
"It must not exceed x.shape[axis]-1, which is %d.")
|
98 |
+
% (n, x.shape[axis] - 1))
|
99 |
+
left_end = axis_slice(x, start=0, stop=1, axis=axis)
|
100 |
+
left_ext = axis_slice(x, start=n, stop=0, step=-1, axis=axis)
|
101 |
+
right_end = axis_slice(x, start=-1, axis=axis)
|
102 |
+
right_ext = axis_slice(x, start=-2, stop=-(n + 2), step=-1, axis=axis)
|
103 |
+
ext = np.concatenate((2 * left_end - left_ext,
|
104 |
+
x,
|
105 |
+
2 * right_end - right_ext),
|
106 |
+
axis=axis)
|
107 |
+
return ext
|
108 |
+
|
109 |
+
|
110 |
+
def even_ext(x, n, axis=-1):
|
111 |
+
"""
|
112 |
+
Even extension at the boundaries of an array
|
113 |
+
|
114 |
+
Generate a new ndarray by making an even extension of `x` along an axis.
|
115 |
+
|
116 |
+
Parameters
|
117 |
+
----------
|
118 |
+
x : ndarray
|
119 |
+
The array to be extended.
|
120 |
+
n : int
|
121 |
+
The number of elements by which to extend `x` at each end of the axis.
|
122 |
+
axis : int, optional
|
123 |
+
The axis along which to extend `x`. Default is -1.
|
124 |
+
|
125 |
+
Examples
|
126 |
+
--------
|
127 |
+
>>> import numpy as np
|
128 |
+
>>> from scipy.signal._arraytools import even_ext
|
129 |
+
>>> a = np.array([[1, 2, 3, 4, 5], [0, 1, 4, 9, 16]])
|
130 |
+
>>> even_ext(a, 2)
|
131 |
+
array([[ 3, 2, 1, 2, 3, 4, 5, 4, 3],
|
132 |
+
[ 4, 1, 0, 1, 4, 9, 16, 9, 4]])
|
133 |
+
|
134 |
+
Even extension is a "mirror image" at the boundaries of the original array:
|
135 |
+
|
136 |
+
>>> t = np.linspace(0, 1.5, 100)
|
137 |
+
>>> a = 0.9 * np.sin(2 * np.pi * t**2)
|
138 |
+
>>> b = even_ext(a, 40)
|
139 |
+
>>> import matplotlib.pyplot as plt
|
140 |
+
>>> plt.plot(np.arange(-40, 140), b, 'b', lw=1, label='even extension')
|
141 |
+
>>> plt.plot(np.arange(100), a, 'r', lw=2, label='original')
|
142 |
+
>>> plt.legend(loc='best')
|
143 |
+
>>> plt.show()
|
144 |
+
"""
|
145 |
+
if n < 1:
|
146 |
+
return x
|
147 |
+
if n > x.shape[axis] - 1:
|
148 |
+
raise ValueError(("The extension length n (%d) is too big. " +
|
149 |
+
"It must not exceed x.shape[axis]-1, which is %d.")
|
150 |
+
% (n, x.shape[axis] - 1))
|
151 |
+
left_ext = axis_slice(x, start=n, stop=0, step=-1, axis=axis)
|
152 |
+
right_ext = axis_slice(x, start=-2, stop=-(n + 2), step=-1, axis=axis)
|
153 |
+
ext = np.concatenate((left_ext,
|
154 |
+
x,
|
155 |
+
right_ext),
|
156 |
+
axis=axis)
|
157 |
+
return ext
|
158 |
+
|
159 |
+
|
160 |
+
def const_ext(x, n, axis=-1):
|
161 |
+
"""
|
162 |
+
Constant extension at the boundaries of an array
|
163 |
+
|
164 |
+
Generate a new ndarray that is a constant extension of `x` along an axis.
|
165 |
+
|
166 |
+
The extension repeats the values at the first and last element of
|
167 |
+
the axis.
|
168 |
+
|
169 |
+
Parameters
|
170 |
+
----------
|
171 |
+
x : ndarray
|
172 |
+
The array to be extended.
|
173 |
+
n : int
|
174 |
+
The number of elements by which to extend `x` at each end of the axis.
|
175 |
+
axis : int, optional
|
176 |
+
The axis along which to extend `x`. Default is -1.
|
177 |
+
|
178 |
+
Examples
|
179 |
+
--------
|
180 |
+
>>> import numpy as np
|
181 |
+
>>> from scipy.signal._arraytools import const_ext
|
182 |
+
>>> a = np.array([[1, 2, 3, 4, 5], [0, 1, 4, 9, 16]])
|
183 |
+
>>> const_ext(a, 2)
|
184 |
+
array([[ 1, 1, 1, 2, 3, 4, 5, 5, 5],
|
185 |
+
[ 0, 0, 0, 1, 4, 9, 16, 16, 16]])
|
186 |
+
|
187 |
+
Constant extension continues with the same values as the endpoints of the
|
188 |
+
array:
|
189 |
+
|
190 |
+
>>> t = np.linspace(0, 1.5, 100)
|
191 |
+
>>> a = 0.9 * np.sin(2 * np.pi * t**2)
|
192 |
+
>>> b = const_ext(a, 40)
|
193 |
+
>>> import matplotlib.pyplot as plt
|
194 |
+
>>> plt.plot(np.arange(-40, 140), b, 'b', lw=1, label='constant extension')
|
195 |
+
>>> plt.plot(np.arange(100), a, 'r', lw=2, label='original')
|
196 |
+
>>> plt.legend(loc='best')
|
197 |
+
>>> plt.show()
|
198 |
+
"""
|
199 |
+
if n < 1:
|
200 |
+
return x
|
201 |
+
left_end = axis_slice(x, start=0, stop=1, axis=axis)
|
202 |
+
ones_shape = [1] * x.ndim
|
203 |
+
ones_shape[axis] = n
|
204 |
+
ones = np.ones(ones_shape, dtype=x.dtype)
|
205 |
+
left_ext = ones * left_end
|
206 |
+
right_end = axis_slice(x, start=-1, axis=axis)
|
207 |
+
right_ext = ones * right_end
|
208 |
+
ext = np.concatenate((left_ext,
|
209 |
+
x,
|
210 |
+
right_ext),
|
211 |
+
axis=axis)
|
212 |
+
return ext
|
213 |
+
|
214 |
+
|
215 |
+
def zero_ext(x, n, axis=-1):
|
216 |
+
"""
|
217 |
+
Zero padding at the boundaries of an array
|
218 |
+
|
219 |
+
Generate a new ndarray that is a zero-padded extension of `x` along
|
220 |
+
an axis.
|
221 |
+
|
222 |
+
Parameters
|
223 |
+
----------
|
224 |
+
x : ndarray
|
225 |
+
The array to be extended.
|
226 |
+
n : int
|
227 |
+
The number of elements by which to extend `x` at each end of the
|
228 |
+
axis.
|
229 |
+
axis : int, optional
|
230 |
+
The axis along which to extend `x`. Default is -1.
|
231 |
+
|
232 |
+
Examples
|
233 |
+
--------
|
234 |
+
>>> import numpy as np
|
235 |
+
>>> from scipy.signal._arraytools import zero_ext
|
236 |
+
>>> a = np.array([[1, 2, 3, 4, 5], [0, 1, 4, 9, 16]])
|
237 |
+
>>> zero_ext(a, 2)
|
238 |
+
array([[ 0, 0, 1, 2, 3, 4, 5, 0, 0],
|
239 |
+
[ 0, 0, 0, 1, 4, 9, 16, 0, 0]])
|
240 |
+
"""
|
241 |
+
if n < 1:
|
242 |
+
return x
|
243 |
+
zeros_shape = list(x.shape)
|
244 |
+
zeros_shape[axis] = n
|
245 |
+
zeros = np.zeros(zeros_shape, dtype=x.dtype)
|
246 |
+
ext = np.concatenate((zeros, x, zeros), axis=axis)
|
247 |
+
return ext
|
248 |
+
|
249 |
+
|
250 |
+
def _validate_fs(fs, allow_none=True):
|
251 |
+
"""
|
252 |
+
Check if the given sampling frequency is a scalar and raises an exception
|
253 |
+
otherwise. If allow_none is False, also raises an exception for none
|
254 |
+
sampling rates. Returns the sampling frequency as float or none if the
|
255 |
+
input is none.
|
256 |
+
"""
|
257 |
+
if fs is None:
|
258 |
+
if not allow_none:
|
259 |
+
raise ValueError("Sampling frequency can not be none.")
|
260 |
+
else: # should be float
|
261 |
+
if not np.isscalar(fs):
|
262 |
+
raise ValueError("Sampling frequency fs must be a single scalar.")
|
263 |
+
fs = float(fs)
|
264 |
+
return fs
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_bsplines.py
ADDED
@@ -0,0 +1,519 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from numpy import (asarray, pi, zeros_like,
|
2 |
+
array, arctan2, tan, ones, arange, floor,
|
3 |
+
r_, atleast_1d, sqrt, exp, greater, cos, add, sin)
|
4 |
+
|
5 |
+
# From splinemodule.c
|
6 |
+
from ._spline import cspline2d, sepfir2d
|
7 |
+
from ._signaltools import lfilter, sosfilt, lfiltic
|
8 |
+
|
9 |
+
from scipy.interpolate import BSpline
|
10 |
+
|
11 |
+
__all__ = ['spline_filter', 'gauss_spline',
|
12 |
+
'cspline1d', 'qspline1d', 'cspline1d_eval', 'qspline1d_eval']
|
13 |
+
|
14 |
+
|
15 |
+
def spline_filter(Iin, lmbda=5.0):
|
16 |
+
"""Smoothing spline (cubic) filtering of a rank-2 array.
|
17 |
+
|
18 |
+
Filter an input data set, `Iin`, using a (cubic) smoothing spline of
|
19 |
+
fall-off `lmbda`.
|
20 |
+
|
21 |
+
Parameters
|
22 |
+
----------
|
23 |
+
Iin : array_like
|
24 |
+
input data set
|
25 |
+
lmbda : float, optional
|
26 |
+
spline smooghing fall-off value, default is `5.0`.
|
27 |
+
|
28 |
+
Returns
|
29 |
+
-------
|
30 |
+
res : ndarray
|
31 |
+
filtered input data
|
32 |
+
|
33 |
+
Examples
|
34 |
+
--------
|
35 |
+
We can filter an multi dimensional signal (ex: 2D image) using cubic
|
36 |
+
B-spline filter:
|
37 |
+
|
38 |
+
>>> import numpy as np
|
39 |
+
>>> from scipy.signal import spline_filter
|
40 |
+
>>> import matplotlib.pyplot as plt
|
41 |
+
>>> orig_img = np.eye(20) # create an image
|
42 |
+
>>> orig_img[10, :] = 1.0
|
43 |
+
>>> sp_filter = spline_filter(orig_img, lmbda=0.1)
|
44 |
+
>>> f, ax = plt.subplots(1, 2, sharex=True)
|
45 |
+
>>> for ind, data in enumerate([[orig_img, "original image"],
|
46 |
+
... [sp_filter, "spline filter"]]):
|
47 |
+
... ax[ind].imshow(data[0], cmap='gray_r')
|
48 |
+
... ax[ind].set_title(data[1])
|
49 |
+
>>> plt.tight_layout()
|
50 |
+
>>> plt.show()
|
51 |
+
|
52 |
+
"""
|
53 |
+
intype = Iin.dtype.char
|
54 |
+
hcol = array([1.0, 4.0, 1.0], 'f') / 6.0
|
55 |
+
if intype in ['F', 'D']:
|
56 |
+
Iin = Iin.astype('F')
|
57 |
+
ckr = cspline2d(Iin.real, lmbda)
|
58 |
+
cki = cspline2d(Iin.imag, lmbda)
|
59 |
+
outr = sepfir2d(ckr, hcol, hcol)
|
60 |
+
outi = sepfir2d(cki, hcol, hcol)
|
61 |
+
out = (outr + 1j * outi).astype(intype)
|
62 |
+
elif intype in ['f', 'd']:
|
63 |
+
ckr = cspline2d(Iin, lmbda)
|
64 |
+
out = sepfir2d(ckr, hcol, hcol)
|
65 |
+
out = out.astype(intype)
|
66 |
+
else:
|
67 |
+
raise TypeError("Invalid data type for Iin")
|
68 |
+
return out
|
69 |
+
|
70 |
+
|
71 |
+
_splinefunc_cache = {}
|
72 |
+
|
73 |
+
|
74 |
+
def gauss_spline(x, n):
|
75 |
+
r"""Gaussian approximation to B-spline basis function of order n.
|
76 |
+
|
77 |
+
Parameters
|
78 |
+
----------
|
79 |
+
x : array_like
|
80 |
+
a knot vector
|
81 |
+
n : int
|
82 |
+
The order of the spline. Must be non-negative, i.e., n >= 0
|
83 |
+
|
84 |
+
Returns
|
85 |
+
-------
|
86 |
+
res : ndarray
|
87 |
+
B-spline basis function values approximated by a zero-mean Gaussian
|
88 |
+
function.
|
89 |
+
|
90 |
+
Notes
|
91 |
+
-----
|
92 |
+
The B-spline basis function can be approximated well by a zero-mean
|
93 |
+
Gaussian function with standard-deviation equal to :math:`\sigma=(n+1)/12`
|
94 |
+
for large `n` :
|
95 |
+
|
96 |
+
.. math:: \frac{1}{\sqrt {2\pi\sigma^2}}exp(-\frac{x^2}{2\sigma})
|
97 |
+
|
98 |
+
References
|
99 |
+
----------
|
100 |
+
.. [1] Bouma H., Vilanova A., Bescos J.O., ter Haar Romeny B.M., Gerritsen
|
101 |
+
F.A. (2007) Fast and Accurate Gaussian Derivatives Based on B-Splines. In:
|
102 |
+
Sgallari F., Murli A., Paragios N. (eds) Scale Space and Variational
|
103 |
+
Methods in Computer Vision. SSVM 2007. Lecture Notes in Computer
|
104 |
+
Science, vol 4485. Springer, Berlin, Heidelberg
|
105 |
+
.. [2] http://folk.uio.no/inf3330/scripting/doc/python/SciPy/tutorial/old/node24.html
|
106 |
+
|
107 |
+
Examples
|
108 |
+
--------
|
109 |
+
We can calculate B-Spline basis functions approximated by a gaussian
|
110 |
+
distribution:
|
111 |
+
|
112 |
+
>>> import numpy as np
|
113 |
+
>>> from scipy.signal import gauss_spline
|
114 |
+
>>> knots = np.array([-1.0, 0.0, -1.0])
|
115 |
+
>>> gauss_spline(knots, 3)
|
116 |
+
array([0.15418033, 0.6909883, 0.15418033]) # may vary
|
117 |
+
|
118 |
+
"""
|
119 |
+
x = asarray(x)
|
120 |
+
signsq = (n + 1) / 12.0
|
121 |
+
return 1 / sqrt(2 * pi * signsq) * exp(-x ** 2 / 2 / signsq)
|
122 |
+
|
123 |
+
|
124 |
+
def _cubic(x):
|
125 |
+
x = asarray(x, dtype=float)
|
126 |
+
b = BSpline.basis_element([-2, -1, 0, 1, 2], extrapolate=False)
|
127 |
+
out = b(x)
|
128 |
+
out[(x < -2) | (x > 2)] = 0
|
129 |
+
return out
|
130 |
+
|
131 |
+
|
132 |
+
def _quadratic(x):
|
133 |
+
x = abs(asarray(x, dtype=float))
|
134 |
+
b = BSpline.basis_element([-1.5, -0.5, 0.5, 1.5], extrapolate=False)
|
135 |
+
out = b(x)
|
136 |
+
out[(x < -1.5) | (x > 1.5)] = 0
|
137 |
+
return out
|
138 |
+
|
139 |
+
|
140 |
+
def _coeff_smooth(lam):
|
141 |
+
xi = 1 - 96 * lam + 24 * lam * sqrt(3 + 144 * lam)
|
142 |
+
omeg = arctan2(sqrt(144 * lam - 1), sqrt(xi))
|
143 |
+
rho = (24 * lam - 1 - sqrt(xi)) / (24 * lam)
|
144 |
+
rho = rho * sqrt((48 * lam + 24 * lam * sqrt(3 + 144 * lam)) / xi)
|
145 |
+
return rho, omeg
|
146 |
+
|
147 |
+
|
148 |
+
def _hc(k, cs, rho, omega):
|
149 |
+
return (cs / sin(omega) * (rho ** k) * sin(omega * (k + 1)) *
|
150 |
+
greater(k, -1))
|
151 |
+
|
152 |
+
|
153 |
+
def _hs(k, cs, rho, omega):
|
154 |
+
c0 = (cs * cs * (1 + rho * rho) / (1 - rho * rho) /
|
155 |
+
(1 - 2 * rho * rho * cos(2 * omega) + rho ** 4))
|
156 |
+
gamma = (1 - rho * rho) / (1 + rho * rho) / tan(omega)
|
157 |
+
ak = abs(k)
|
158 |
+
return c0 * rho ** ak * (cos(omega * ak) + gamma * sin(omega * ak))
|
159 |
+
|
160 |
+
|
161 |
+
def _cubic_smooth_coeff(signal, lamb):
|
162 |
+
rho, omega = _coeff_smooth(lamb)
|
163 |
+
cs = 1 - 2 * rho * cos(omega) + rho * rho
|
164 |
+
K = len(signal)
|
165 |
+
k = arange(K)
|
166 |
+
|
167 |
+
zi_2 = (_hc(0, cs, rho, omega) * signal[0] +
|
168 |
+
add.reduce(_hc(k + 1, cs, rho, omega) * signal))
|
169 |
+
zi_1 = (_hc(0, cs, rho, omega) * signal[0] +
|
170 |
+
_hc(1, cs, rho, omega) * signal[1] +
|
171 |
+
add.reduce(_hc(k + 2, cs, rho, omega) * signal))
|
172 |
+
|
173 |
+
# Forward filter:
|
174 |
+
# for n in range(2, K):
|
175 |
+
# yp[n] = (cs * signal[n] + 2 * rho * cos(omega) * yp[n - 1] -
|
176 |
+
# rho * rho * yp[n - 2])
|
177 |
+
zi = lfiltic(cs, r_[1, -2 * rho * cos(omega), rho * rho], r_[zi_1, zi_2])
|
178 |
+
zi = zi.reshape(1, -1)
|
179 |
+
|
180 |
+
sos = r_[cs, 0, 0, 1, -2 * rho * cos(omega), rho * rho]
|
181 |
+
sos = sos.reshape(1, -1)
|
182 |
+
|
183 |
+
yp, _ = sosfilt(sos, signal[2:], zi=zi)
|
184 |
+
yp = r_[zi_2, zi_1, yp]
|
185 |
+
|
186 |
+
# Reverse filter:
|
187 |
+
# for n in range(K - 3, -1, -1):
|
188 |
+
# y[n] = (cs * yp[n] + 2 * rho * cos(omega) * y[n + 1] -
|
189 |
+
# rho * rho * y[n + 2])
|
190 |
+
|
191 |
+
zi_2 = add.reduce((_hs(k, cs, rho, omega) +
|
192 |
+
_hs(k + 1, cs, rho, omega)) * signal[::-1])
|
193 |
+
zi_1 = add.reduce((_hs(k - 1, cs, rho, omega) +
|
194 |
+
_hs(k + 2, cs, rho, omega)) * signal[::-1])
|
195 |
+
|
196 |
+
zi = lfiltic(cs, r_[1, -2 * rho * cos(omega), rho * rho], r_[zi_1, zi_2])
|
197 |
+
zi = zi.reshape(1, -1)
|
198 |
+
y, _ = sosfilt(sos, yp[-3::-1], zi=zi)
|
199 |
+
y = r_[y[::-1], zi_1, zi_2]
|
200 |
+
return y
|
201 |
+
|
202 |
+
|
203 |
+
def _cubic_coeff(signal):
|
204 |
+
zi = -2 + sqrt(3)
|
205 |
+
K = len(signal)
|
206 |
+
powers = zi ** arange(K)
|
207 |
+
|
208 |
+
if K == 1:
|
209 |
+
yplus = signal[0] + zi * add.reduce(powers * signal)
|
210 |
+
output = zi / (zi - 1) * yplus
|
211 |
+
return atleast_1d(output)
|
212 |
+
|
213 |
+
# Forward filter:
|
214 |
+
# yplus[0] = signal[0] + zi * add.reduce(powers * signal)
|
215 |
+
# for k in range(1, K):
|
216 |
+
# yplus[k] = signal[k] + zi * yplus[k - 1]
|
217 |
+
|
218 |
+
state = lfiltic(1, r_[1, -zi], atleast_1d(add.reduce(powers * signal)))
|
219 |
+
|
220 |
+
b = ones(1)
|
221 |
+
a = r_[1, -zi]
|
222 |
+
yplus, _ = lfilter(b, a, signal, zi=state)
|
223 |
+
|
224 |
+
# Reverse filter:
|
225 |
+
# output[K - 1] = zi / (zi - 1) * yplus[K - 1]
|
226 |
+
# for k in range(K - 2, -1, -1):
|
227 |
+
# output[k] = zi * (output[k + 1] - yplus[k])
|
228 |
+
out_last = zi / (zi - 1) * yplus[K - 1]
|
229 |
+
state = lfiltic(-zi, r_[1, -zi], atleast_1d(out_last))
|
230 |
+
|
231 |
+
b = asarray([-zi])
|
232 |
+
output, _ = lfilter(b, a, yplus[-2::-1], zi=state)
|
233 |
+
output = r_[output[::-1], out_last]
|
234 |
+
return output * 6.0
|
235 |
+
|
236 |
+
|
237 |
+
def _quadratic_coeff(signal):
|
238 |
+
zi = -3 + 2 * sqrt(2.0)
|
239 |
+
K = len(signal)
|
240 |
+
powers = zi ** arange(K)
|
241 |
+
|
242 |
+
if K == 1:
|
243 |
+
yplus = signal[0] + zi * add.reduce(powers * signal)
|
244 |
+
output = zi / (zi - 1) * yplus
|
245 |
+
return atleast_1d(output)
|
246 |
+
|
247 |
+
# Forward filter:
|
248 |
+
# yplus[0] = signal[0] + zi * add.reduce(powers * signal)
|
249 |
+
# for k in range(1, K):
|
250 |
+
# yplus[k] = signal[k] + zi * yplus[k - 1]
|
251 |
+
|
252 |
+
state = lfiltic(1, r_[1, -zi], atleast_1d(add.reduce(powers * signal)))
|
253 |
+
|
254 |
+
b = ones(1)
|
255 |
+
a = r_[1, -zi]
|
256 |
+
yplus, _ = lfilter(b, a, signal, zi=state)
|
257 |
+
|
258 |
+
# Reverse filter:
|
259 |
+
# output[K - 1] = zi / (zi - 1) * yplus[K - 1]
|
260 |
+
# for k in range(K - 2, -1, -1):
|
261 |
+
# output[k] = zi * (output[k + 1] - yplus[k])
|
262 |
+
out_last = zi / (zi - 1) * yplus[K - 1]
|
263 |
+
state = lfiltic(-zi, r_[1, -zi], atleast_1d(out_last))
|
264 |
+
|
265 |
+
b = asarray([-zi])
|
266 |
+
output, _ = lfilter(b, a, yplus[-2::-1], zi=state)
|
267 |
+
output = r_[output[::-1], out_last]
|
268 |
+
return output * 8.0
|
269 |
+
|
270 |
+
|
271 |
+
def cspline1d(signal, lamb=0.0):
|
272 |
+
"""
|
273 |
+
Compute cubic spline coefficients for rank-1 array.
|
274 |
+
|
275 |
+
Find the cubic spline coefficients for a 1-D signal assuming
|
276 |
+
mirror-symmetric boundary conditions. To obtain the signal back from the
|
277 |
+
spline representation mirror-symmetric-convolve these coefficients with a
|
278 |
+
length 3 FIR window [1.0, 4.0, 1.0]/ 6.0 .
|
279 |
+
|
280 |
+
Parameters
|
281 |
+
----------
|
282 |
+
signal : ndarray
|
283 |
+
A rank-1 array representing samples of a signal.
|
284 |
+
lamb : float, optional
|
285 |
+
Smoothing coefficient, default is 0.0.
|
286 |
+
|
287 |
+
Returns
|
288 |
+
-------
|
289 |
+
c : ndarray
|
290 |
+
Cubic spline coefficients.
|
291 |
+
|
292 |
+
See Also
|
293 |
+
--------
|
294 |
+
cspline1d_eval : Evaluate a cubic spline at the new set of points.
|
295 |
+
|
296 |
+
Examples
|
297 |
+
--------
|
298 |
+
We can filter a signal to reduce and smooth out high-frequency noise with
|
299 |
+
a cubic spline:
|
300 |
+
|
301 |
+
>>> import numpy as np
|
302 |
+
>>> import matplotlib.pyplot as plt
|
303 |
+
>>> from scipy.signal import cspline1d, cspline1d_eval
|
304 |
+
>>> rng = np.random.default_rng()
|
305 |
+
>>> sig = np.repeat([0., 1., 0.], 100)
|
306 |
+
>>> sig += rng.standard_normal(len(sig))*0.05 # add noise
|
307 |
+
>>> time = np.linspace(0, len(sig))
|
308 |
+
>>> filtered = cspline1d_eval(cspline1d(sig), time)
|
309 |
+
>>> plt.plot(sig, label="signal")
|
310 |
+
>>> plt.plot(time, filtered, label="filtered")
|
311 |
+
>>> plt.legend()
|
312 |
+
>>> plt.show()
|
313 |
+
|
314 |
+
"""
|
315 |
+
if lamb != 0.0:
|
316 |
+
return _cubic_smooth_coeff(signal, lamb)
|
317 |
+
else:
|
318 |
+
return _cubic_coeff(signal)
|
319 |
+
|
320 |
+
|
321 |
+
def qspline1d(signal, lamb=0.0):
|
322 |
+
"""Compute quadratic spline coefficients for rank-1 array.
|
323 |
+
|
324 |
+
Parameters
|
325 |
+
----------
|
326 |
+
signal : ndarray
|
327 |
+
A rank-1 array representing samples of a signal.
|
328 |
+
lamb : float, optional
|
329 |
+
Smoothing coefficient (must be zero for now).
|
330 |
+
|
331 |
+
Returns
|
332 |
+
-------
|
333 |
+
c : ndarray
|
334 |
+
Quadratic spline coefficients.
|
335 |
+
|
336 |
+
See Also
|
337 |
+
--------
|
338 |
+
qspline1d_eval : Evaluate a quadratic spline at the new set of points.
|
339 |
+
|
340 |
+
Notes
|
341 |
+
-----
|
342 |
+
Find the quadratic spline coefficients for a 1-D signal assuming
|
343 |
+
mirror-symmetric boundary conditions. To obtain the signal back from the
|
344 |
+
spline representation mirror-symmetric-convolve these coefficients with a
|
345 |
+
length 3 FIR window [1.0, 6.0, 1.0]/ 8.0 .
|
346 |
+
|
347 |
+
Examples
|
348 |
+
--------
|
349 |
+
We can filter a signal to reduce and smooth out high-frequency noise with
|
350 |
+
a quadratic spline:
|
351 |
+
|
352 |
+
>>> import numpy as np
|
353 |
+
>>> import matplotlib.pyplot as plt
|
354 |
+
>>> from scipy.signal import qspline1d, qspline1d_eval
|
355 |
+
>>> rng = np.random.default_rng()
|
356 |
+
>>> sig = np.repeat([0., 1., 0.], 100)
|
357 |
+
>>> sig += rng.standard_normal(len(sig))*0.05 # add noise
|
358 |
+
>>> time = np.linspace(0, len(sig))
|
359 |
+
>>> filtered = qspline1d_eval(qspline1d(sig), time)
|
360 |
+
>>> plt.plot(sig, label="signal")
|
361 |
+
>>> plt.plot(time, filtered, label="filtered")
|
362 |
+
>>> plt.legend()
|
363 |
+
>>> plt.show()
|
364 |
+
|
365 |
+
"""
|
366 |
+
if lamb != 0.0:
|
367 |
+
raise ValueError("Smoothing quadratic splines not supported yet.")
|
368 |
+
else:
|
369 |
+
return _quadratic_coeff(signal)
|
370 |
+
|
371 |
+
|
372 |
+
def cspline1d_eval(cj, newx, dx=1.0, x0=0):
|
373 |
+
"""Evaluate a cubic spline at the new set of points.
|
374 |
+
|
375 |
+
`dx` is the old sample-spacing while `x0` was the old origin. In
|
376 |
+
other-words the old-sample points (knot-points) for which the `cj`
|
377 |
+
represent spline coefficients were at equally-spaced points of:
|
378 |
+
|
379 |
+
oldx = x0 + j*dx j=0...N-1, with N=len(cj)
|
380 |
+
|
381 |
+
Edges are handled using mirror-symmetric boundary conditions.
|
382 |
+
|
383 |
+
Parameters
|
384 |
+
----------
|
385 |
+
cj : ndarray
|
386 |
+
cublic spline coefficients
|
387 |
+
newx : ndarray
|
388 |
+
New set of points.
|
389 |
+
dx : float, optional
|
390 |
+
Old sample-spacing, the default value is 1.0.
|
391 |
+
x0 : int, optional
|
392 |
+
Old origin, the default value is 0.
|
393 |
+
|
394 |
+
Returns
|
395 |
+
-------
|
396 |
+
res : ndarray
|
397 |
+
Evaluated a cubic spline points.
|
398 |
+
|
399 |
+
See Also
|
400 |
+
--------
|
401 |
+
cspline1d : Compute cubic spline coefficients for rank-1 array.
|
402 |
+
|
403 |
+
Examples
|
404 |
+
--------
|
405 |
+
We can filter a signal to reduce and smooth out high-frequency noise with
|
406 |
+
a cubic spline:
|
407 |
+
|
408 |
+
>>> import numpy as np
|
409 |
+
>>> import matplotlib.pyplot as plt
|
410 |
+
>>> from scipy.signal import cspline1d, cspline1d_eval
|
411 |
+
>>> rng = np.random.default_rng()
|
412 |
+
>>> sig = np.repeat([0., 1., 0.], 100)
|
413 |
+
>>> sig += rng.standard_normal(len(sig))*0.05 # add noise
|
414 |
+
>>> time = np.linspace(0, len(sig))
|
415 |
+
>>> filtered = cspline1d_eval(cspline1d(sig), time)
|
416 |
+
>>> plt.plot(sig, label="signal")
|
417 |
+
>>> plt.plot(time, filtered, label="filtered")
|
418 |
+
>>> plt.legend()
|
419 |
+
>>> plt.show()
|
420 |
+
|
421 |
+
"""
|
422 |
+
newx = (asarray(newx) - x0) / float(dx)
|
423 |
+
res = zeros_like(newx, dtype=cj.dtype)
|
424 |
+
if res.size == 0:
|
425 |
+
return res
|
426 |
+
N = len(cj)
|
427 |
+
cond1 = newx < 0
|
428 |
+
cond2 = newx > (N - 1)
|
429 |
+
cond3 = ~(cond1 | cond2)
|
430 |
+
# handle general mirror-symmetry
|
431 |
+
res[cond1] = cspline1d_eval(cj, -newx[cond1])
|
432 |
+
res[cond2] = cspline1d_eval(cj, 2 * (N - 1) - newx[cond2])
|
433 |
+
newx = newx[cond3]
|
434 |
+
if newx.size == 0:
|
435 |
+
return res
|
436 |
+
result = zeros_like(newx, dtype=cj.dtype)
|
437 |
+
jlower = floor(newx - 2).astype(int) + 1
|
438 |
+
for i in range(4):
|
439 |
+
thisj = jlower + i
|
440 |
+
indj = thisj.clip(0, N - 1) # handle edge cases
|
441 |
+
result += cj[indj] * _cubic(newx - thisj)
|
442 |
+
res[cond3] = result
|
443 |
+
return res
|
444 |
+
|
445 |
+
|
446 |
+
def qspline1d_eval(cj, newx, dx=1.0, x0=0):
|
447 |
+
"""Evaluate a quadratic spline at the new set of points.
|
448 |
+
|
449 |
+
Parameters
|
450 |
+
----------
|
451 |
+
cj : ndarray
|
452 |
+
Quadratic spline coefficients
|
453 |
+
newx : ndarray
|
454 |
+
New set of points.
|
455 |
+
dx : float, optional
|
456 |
+
Old sample-spacing, the default value is 1.0.
|
457 |
+
x0 : int, optional
|
458 |
+
Old origin, the default value is 0.
|
459 |
+
|
460 |
+
Returns
|
461 |
+
-------
|
462 |
+
res : ndarray
|
463 |
+
Evaluated a quadratic spline points.
|
464 |
+
|
465 |
+
See Also
|
466 |
+
--------
|
467 |
+
qspline1d : Compute quadratic spline coefficients for rank-1 array.
|
468 |
+
|
469 |
+
Notes
|
470 |
+
-----
|
471 |
+
`dx` is the old sample-spacing while `x0` was the old origin. In
|
472 |
+
other-words the old-sample points (knot-points) for which the `cj`
|
473 |
+
represent spline coefficients were at equally-spaced points of::
|
474 |
+
|
475 |
+
oldx = x0 + j*dx j=0...N-1, with N=len(cj)
|
476 |
+
|
477 |
+
Edges are handled using mirror-symmetric boundary conditions.
|
478 |
+
|
479 |
+
Examples
|
480 |
+
--------
|
481 |
+
We can filter a signal to reduce and smooth out high-frequency noise with
|
482 |
+
a quadratic spline:
|
483 |
+
|
484 |
+
>>> import numpy as np
|
485 |
+
>>> import matplotlib.pyplot as plt
|
486 |
+
>>> from scipy.signal import qspline1d, qspline1d_eval
|
487 |
+
>>> rng = np.random.default_rng()
|
488 |
+
>>> sig = np.repeat([0., 1., 0.], 100)
|
489 |
+
>>> sig += rng.standard_normal(len(sig))*0.05 # add noise
|
490 |
+
>>> time = np.linspace(0, len(sig))
|
491 |
+
>>> filtered = qspline1d_eval(qspline1d(sig), time)
|
492 |
+
>>> plt.plot(sig, label="signal")
|
493 |
+
>>> plt.plot(time, filtered, label="filtered")
|
494 |
+
>>> plt.legend()
|
495 |
+
>>> plt.show()
|
496 |
+
|
497 |
+
"""
|
498 |
+
newx = (asarray(newx) - x0) / dx
|
499 |
+
res = zeros_like(newx)
|
500 |
+
if res.size == 0:
|
501 |
+
return res
|
502 |
+
N = len(cj)
|
503 |
+
cond1 = newx < 0
|
504 |
+
cond2 = newx > (N - 1)
|
505 |
+
cond3 = ~(cond1 | cond2)
|
506 |
+
# handle general mirror-symmetry
|
507 |
+
res[cond1] = qspline1d_eval(cj, -newx[cond1])
|
508 |
+
res[cond2] = qspline1d_eval(cj, 2 * (N - 1) - newx[cond2])
|
509 |
+
newx = newx[cond3]
|
510 |
+
if newx.size == 0:
|
511 |
+
return res
|
512 |
+
result = zeros_like(newx)
|
513 |
+
jlower = floor(newx - 1.5).astype(int) + 1
|
514 |
+
for i in range(3):
|
515 |
+
thisj = jlower + i
|
516 |
+
indj = thisj.clip(0, N - 1) # handle edge cases
|
517 |
+
result += cj[indj] * _quadratic(newx - thisj)
|
518 |
+
res[cond3] = result
|
519 |
+
return res
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_max_len_seq.py
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Author: Eric Larson
|
2 |
+
# 2014
|
3 |
+
|
4 |
+
"""Tools for MLS generation"""
|
5 |
+
|
6 |
+
import numpy as np
|
7 |
+
|
8 |
+
from ._max_len_seq_inner import _max_len_seq_inner
|
9 |
+
|
10 |
+
__all__ = ['max_len_seq']
|
11 |
+
|
12 |
+
|
13 |
+
# These are definitions of linear shift register taps for use in max_len_seq()
|
14 |
+
_mls_taps = {2: [1], 3: [2], 4: [3], 5: [3], 6: [5], 7: [6], 8: [7, 6, 1],
|
15 |
+
9: [5], 10: [7], 11: [9], 12: [11, 10, 4], 13: [12, 11, 8],
|
16 |
+
14: [13, 12, 2], 15: [14], 16: [15, 13, 4], 17: [14],
|
17 |
+
18: [11], 19: [18, 17, 14], 20: [17], 21: [19], 22: [21],
|
18 |
+
23: [18], 24: [23, 22, 17], 25: [22], 26: [25, 24, 20],
|
19 |
+
27: [26, 25, 22], 28: [25], 29: [27], 30: [29, 28, 7],
|
20 |
+
31: [28], 32: [31, 30, 10]}
|
21 |
+
|
22 |
+
def max_len_seq(nbits, state=None, length=None, taps=None):
|
23 |
+
"""
|
24 |
+
Maximum length sequence (MLS) generator.
|
25 |
+
|
26 |
+
Parameters
|
27 |
+
----------
|
28 |
+
nbits : int
|
29 |
+
Number of bits to use. Length of the resulting sequence will
|
30 |
+
be ``(2**nbits) - 1``. Note that generating long sequences
|
31 |
+
(e.g., greater than ``nbits == 16``) can take a long time.
|
32 |
+
state : array_like, optional
|
33 |
+
If array, must be of length ``nbits``, and will be cast to binary
|
34 |
+
(bool) representation. If None, a seed of ones will be used,
|
35 |
+
producing a repeatable representation. If ``state`` is all
|
36 |
+
zeros, an error is raised as this is invalid. Default: None.
|
37 |
+
length : int, optional
|
38 |
+
Number of samples to compute. If None, the entire length
|
39 |
+
``(2**nbits) - 1`` is computed.
|
40 |
+
taps : array_like, optional
|
41 |
+
Polynomial taps to use (e.g., ``[7, 6, 1]`` for an 8-bit sequence).
|
42 |
+
If None, taps will be automatically selected (for up to
|
43 |
+
``nbits == 32``).
|
44 |
+
|
45 |
+
Returns
|
46 |
+
-------
|
47 |
+
seq : array
|
48 |
+
Resulting MLS sequence of 0's and 1's.
|
49 |
+
state : array
|
50 |
+
The final state of the shift register.
|
51 |
+
|
52 |
+
Notes
|
53 |
+
-----
|
54 |
+
The algorithm for MLS generation is generically described in:
|
55 |
+
|
56 |
+
https://en.wikipedia.org/wiki/Maximum_length_sequence
|
57 |
+
|
58 |
+
The default values for taps are specifically taken from the first
|
59 |
+
option listed for each value of ``nbits`` in:
|
60 |
+
|
61 |
+
https://web.archive.org/web/20181001062252/http://www.newwaveinstruments.com/resources/articles/m_sequence_linear_feedback_shift_register_lfsr.htm
|
62 |
+
|
63 |
+
.. versionadded:: 0.15.0
|
64 |
+
|
65 |
+
Examples
|
66 |
+
--------
|
67 |
+
MLS uses binary convention:
|
68 |
+
|
69 |
+
>>> from scipy.signal import max_len_seq
|
70 |
+
>>> max_len_seq(4)[0]
|
71 |
+
array([1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0], dtype=int8)
|
72 |
+
|
73 |
+
MLS has a white spectrum (except for DC):
|
74 |
+
|
75 |
+
>>> import numpy as np
|
76 |
+
>>> import matplotlib.pyplot as plt
|
77 |
+
>>> from numpy.fft import fft, ifft, fftshift, fftfreq
|
78 |
+
>>> seq = max_len_seq(6)[0]*2-1 # +1 and -1
|
79 |
+
>>> spec = fft(seq)
|
80 |
+
>>> N = len(seq)
|
81 |
+
>>> plt.plot(fftshift(fftfreq(N)), fftshift(np.abs(spec)), '.-')
|
82 |
+
>>> plt.margins(0.1, 0.1)
|
83 |
+
>>> plt.grid(True)
|
84 |
+
>>> plt.show()
|
85 |
+
|
86 |
+
Circular autocorrelation of MLS is an impulse:
|
87 |
+
|
88 |
+
>>> acorrcirc = ifft(spec * np.conj(spec)).real
|
89 |
+
>>> plt.figure()
|
90 |
+
>>> plt.plot(np.arange(-N/2+1, N/2+1), fftshift(acorrcirc), '.-')
|
91 |
+
>>> plt.margins(0.1, 0.1)
|
92 |
+
>>> plt.grid(True)
|
93 |
+
>>> plt.show()
|
94 |
+
|
95 |
+
Linear autocorrelation of MLS is approximately an impulse:
|
96 |
+
|
97 |
+
>>> acorr = np.correlate(seq, seq, 'full')
|
98 |
+
>>> plt.figure()
|
99 |
+
>>> plt.plot(np.arange(-N+1, N), acorr, '.-')
|
100 |
+
>>> plt.margins(0.1, 0.1)
|
101 |
+
>>> plt.grid(True)
|
102 |
+
>>> plt.show()
|
103 |
+
|
104 |
+
"""
|
105 |
+
taps_dtype = np.int32 if np.intp().itemsize == 4 else np.int64
|
106 |
+
if taps is None:
|
107 |
+
if nbits not in _mls_taps:
|
108 |
+
known_taps = np.array(list(_mls_taps.keys()))
|
109 |
+
raise ValueError(f'nbits must be between {known_taps.min()} and '
|
110 |
+
f'{known_taps.max()} if taps is None')
|
111 |
+
taps = np.array(_mls_taps[nbits], taps_dtype)
|
112 |
+
else:
|
113 |
+
taps = np.unique(np.array(taps, taps_dtype))[::-1]
|
114 |
+
if np.any(taps < 0) or np.any(taps > nbits) or taps.size < 1:
|
115 |
+
raise ValueError('taps must be non-empty with values between '
|
116 |
+
'zero and nbits (inclusive)')
|
117 |
+
taps = np.array(taps) # needed for Cython and Pythran
|
118 |
+
n_max = (2**nbits) - 1
|
119 |
+
if length is None:
|
120 |
+
length = n_max
|
121 |
+
else:
|
122 |
+
length = int(length)
|
123 |
+
if length < 0:
|
124 |
+
raise ValueError('length must be greater than or equal to 0')
|
125 |
+
# We use int8 instead of bool here because NumPy arrays of bools
|
126 |
+
# don't seem to work nicely with Cython
|
127 |
+
if state is None:
|
128 |
+
state = np.ones(nbits, dtype=np.int8, order='c')
|
129 |
+
else:
|
130 |
+
# makes a copy if need be, ensuring it's 0's and 1's
|
131 |
+
state = np.array(state, dtype=bool, order='c').astype(np.int8)
|
132 |
+
if state.ndim != 1 or state.size != nbits:
|
133 |
+
raise ValueError('state must be a 1-D array of size nbits')
|
134 |
+
if np.all(state == 0):
|
135 |
+
raise ValueError('state must not be all zeros')
|
136 |
+
|
137 |
+
seq = np.empty(length, dtype=np.int8, order='c')
|
138 |
+
state = _max_len_seq_inner(taps, state, nbits, length, seq)
|
139 |
+
return seq, state
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_max_len_seq_inner.cpython-310-x86_64-linux-gnu.so
ADDED
Binary file (77.8 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_short_time_fft.py
ADDED
@@ -0,0 +1,1676 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Implementation of an FFT-based Short-time Fourier Transform. """
|
2 |
+
|
3 |
+
# Implementation Notes for this file (as of 2023-07)
|
4 |
+
# --------------------------------------------------
|
5 |
+
# * MyPy version 1.1.1 does not seem to support decorated property methods
|
6 |
+
# properly. Hence, applying ``@property`` to methods decorated with `@cache``
|
7 |
+
# (as tried with the ``lower_border_end`` method) causes a mypy error when
|
8 |
+
# accessing it as an index (e.g., ``SFT.lower_border_end[0]``).
|
9 |
+
# * Since the method `stft` and `istft` have identical names as the legacy
|
10 |
+
# functions in the signal module, referencing them as HTML link in the
|
11 |
+
# docstrings has to be done by an explicit `~ShortTimeFFT.stft` instead of an
|
12 |
+
# ambiguous `stft` (The ``~`` hides the class / module name).
|
13 |
+
# * The HTML documentation currently renders each method/property on a separate
|
14 |
+
# page without reference to the parent class. Thus, a link to `ShortTimeFFT`
|
15 |
+
# was added to the "See Also" section of each method/property. These links
|
16 |
+
# can be removed, when SciPy updates ``pydata-sphinx-theme`` to >= 0.13.3
|
17 |
+
# (currently 0.9). Consult Issue 18512 and PR 16660 for further details.
|
18 |
+
#
|
19 |
+
|
20 |
+
# Provides typing union operator ``|`` in Python 3.9:
|
21 |
+
from __future__ import annotations
|
22 |
+
# Linter does not allow to import ``Generator`` from ``typing`` module:
|
23 |
+
from collections.abc import Generator
|
24 |
+
from functools import cache, lru_cache, partial
|
25 |
+
from typing import Callable, get_args, Literal
|
26 |
+
|
27 |
+
import numpy as np
|
28 |
+
|
29 |
+
import scipy.fft as fft_lib
|
30 |
+
from scipy.signal import detrend
|
31 |
+
from scipy.signal.windows import get_window
|
32 |
+
|
33 |
+
__all__ = ['ShortTimeFFT']
|
34 |
+
|
35 |
+
|
36 |
+
#: Allowed values for parameter `padding` of method `ShortTimeFFT.stft()`:
|
37 |
+
PAD_TYPE = Literal['zeros', 'edge', 'even', 'odd']
|
38 |
+
|
39 |
+
#: Allowed values for property `ShortTimeFFT.fft_mode`:
|
40 |
+
FFT_MODE_TYPE = Literal['twosided', 'centered', 'onesided', 'onesided2X']
|
41 |
+
|
42 |
+
|
43 |
+
def _calc_dual_canonical_window(win: np.ndarray, hop: int) -> np.ndarray:
|
44 |
+
"""Calculate canonical dual window for 1d window `win` and a time step
|
45 |
+
of `hop` samples.
|
46 |
+
|
47 |
+
A ``ValueError`` is raised, if the inversion fails.
|
48 |
+
|
49 |
+
This is a separate function not a method, since it is also used in the
|
50 |
+
class method ``ShortTimeFFT.from_dual()``.
|
51 |
+
"""
|
52 |
+
if hop > len(win):
|
53 |
+
raise ValueError(f"{hop=} is larger than window length of {len(win)}" +
|
54 |
+
" => STFT not invertible!")
|
55 |
+
if issubclass(win.dtype.type, np.integer):
|
56 |
+
raise ValueError("Parameter 'win' cannot be of integer type, but " +
|
57 |
+
f"{win.dtype=} => STFT not invertible!")
|
58 |
+
# The calculation of `relative_resolution` does not work for ints.
|
59 |
+
# Furthermore, `win / DD` casts the integers away, thus an implicit
|
60 |
+
# cast is avoided, which can always cause confusion when using 32-Bit
|
61 |
+
# floats.
|
62 |
+
|
63 |
+
w2 = win.real**2 + win.imag**2 # win*win.conj() does not ensure w2 is real
|
64 |
+
DD = w2.copy()
|
65 |
+
for k_ in range(hop, len(win), hop):
|
66 |
+
DD[k_:] += w2[:-k_]
|
67 |
+
DD[:-k_] += w2[k_:]
|
68 |
+
|
69 |
+
# check DD > 0:
|
70 |
+
relative_resolution = np.finfo(win.dtype).resolution * max(DD)
|
71 |
+
if not np.all(DD >= relative_resolution):
|
72 |
+
raise ValueError("Short-time Fourier Transform not invertible!")
|
73 |
+
|
74 |
+
return win / DD
|
75 |
+
|
76 |
+
|
77 |
+
# noinspection PyShadowingNames
|
78 |
+
class ShortTimeFFT:
|
79 |
+
r"""Provide a parametrized discrete Short-time Fourier transform (stft)
|
80 |
+
and its inverse (istft).
|
81 |
+
|
82 |
+
.. currentmodule:: scipy.signal.ShortTimeFFT
|
83 |
+
|
84 |
+
The `~ShortTimeFFT.stft` calculates sequential FFTs by sliding a
|
85 |
+
window (`win`) over an input signal by `hop` increments. It can be used to
|
86 |
+
quantify the change of the spectrum over time.
|
87 |
+
|
88 |
+
The `~ShortTimeFFT.stft` is represented by a complex-valued matrix S[q,p]
|
89 |
+
where the p-th column represents an FFT with the window centered at the
|
90 |
+
time t[p] = p * `delta_t` = p * `hop` * `T` where `T` is the sampling
|
91 |
+
interval of the input signal. The q-th row represents the values at the
|
92 |
+
frequency f[q] = q * `delta_f` with `delta_f` = 1 / (`mfft` * `T`) being
|
93 |
+
the bin width of the FFT.
|
94 |
+
|
95 |
+
The inverse STFT `~ShortTimeFFT.istft` is calculated by reversing the steps
|
96 |
+
of the STFT: Take the IFFT of the p-th slice of S[q,p] and multiply the
|
97 |
+
result with the so-called dual window (see `dual_win`). Shift the result by
|
98 |
+
p * `delta_t` and add the result to previous shifted results to reconstruct
|
99 |
+
the signal. If only the dual window is known and the STFT is invertible,
|
100 |
+
`from_dual` can be used to instantiate this class.
|
101 |
+
|
102 |
+
Due to the convention of time t = 0 being at the first sample of the input
|
103 |
+
signal, the STFT values typically have negative time slots. Hence,
|
104 |
+
negative indexes like `p_min` or `k_min` do not indicate counting
|
105 |
+
backwards from an array's end like in standard Python indexing but being
|
106 |
+
left of t = 0.
|
107 |
+
|
108 |
+
More detailed information can be found in the :ref:`tutorial_stft` section
|
109 |
+
of the :ref:`user_guide`.
|
110 |
+
|
111 |
+
Note that all parameters of the initializer, except `scale_to` (which uses
|
112 |
+
`scaling`) have identical named attributes.
|
113 |
+
|
114 |
+
Parameters
|
115 |
+
----------
|
116 |
+
win : np.ndarray
|
117 |
+
The window must be a real- or complex-valued 1d array.
|
118 |
+
hop : int
|
119 |
+
The increment in samples, by which the window is shifted in each step.
|
120 |
+
fs : float
|
121 |
+
Sampling frequency of input signal and window. Its relation to the
|
122 |
+
sampling interval `T` is ``T = 1 / fs``.
|
123 |
+
fft_mode : 'twosided', 'centered', 'onesided', 'onesided2X'
|
124 |
+
Mode of FFT to be used (default 'onesided').
|
125 |
+
See property `fft_mode` for details.
|
126 |
+
mfft: int | None
|
127 |
+
Length of the FFT used, if a zero padded FFT is desired.
|
128 |
+
If ``None`` (default), the length of the window `win` is used.
|
129 |
+
dual_win : np.ndarray | None
|
130 |
+
The dual window of `win`. If set to ``None``, it is calculated if
|
131 |
+
needed.
|
132 |
+
scale_to : 'magnitude', 'psd' | None
|
133 |
+
If not ``None`` (default) the window function is scaled, so each STFT
|
134 |
+
column represents either a 'magnitude' or a power spectral density
|
135 |
+
('psd') spectrum. This parameter sets the property `scaling` to the
|
136 |
+
same value. See method `scale_to` for details.
|
137 |
+
phase_shift : int | None
|
138 |
+
If set, add a linear phase `phase_shift` / `mfft` * `f` to each
|
139 |
+
frequency `f`. The default value 0 ensures that there is no phase shift
|
140 |
+
on the zeroth slice (in which t=0 is centered). See property
|
141 |
+
`phase_shift` for more details.
|
142 |
+
|
143 |
+
Examples
|
144 |
+
--------
|
145 |
+
The following example shows the magnitude of the STFT of a sine with
|
146 |
+
varying frequency :math:`f_i(t)` (marked by a red dashed line in the plot):
|
147 |
+
|
148 |
+
>>> import numpy as np
|
149 |
+
>>> import matplotlib.pyplot as plt
|
150 |
+
>>> from scipy.signal import ShortTimeFFT
|
151 |
+
>>> from scipy.signal.windows import gaussian
|
152 |
+
...
|
153 |
+
>>> T_x, N = 1 / 20, 1000 # 20 Hz sampling rate for 50 s signal
|
154 |
+
>>> t_x = np.arange(N) * T_x # time indexes for signal
|
155 |
+
>>> f_i = 1 * np.arctan((t_x - t_x[N // 2]) / 2) + 5 # varying frequency
|
156 |
+
>>> x = np.sin(2*np.pi*np.cumsum(f_i)*T_x) # the signal
|
157 |
+
|
158 |
+
The utilized Gaussian window is 50 samples or 2.5 s long. The parameter
|
159 |
+
``mfft=200`` in `ShortTimeFFT` causes the spectrum to be oversampled
|
160 |
+
by a factor of 4:
|
161 |
+
|
162 |
+
>>> g_std = 8 # standard deviation for Gaussian window in samples
|
163 |
+
>>> w = gaussian(50, std=g_std, sym=True) # symmetric Gaussian window
|
164 |
+
>>> SFT = ShortTimeFFT(w, hop=10, fs=1/T_x, mfft=200, scale_to='magnitude')
|
165 |
+
>>> Sx = SFT.stft(x) # perform the STFT
|
166 |
+
|
167 |
+
In the plot, the time extent of the signal `x` is marked by vertical dashed
|
168 |
+
lines. Note that the SFT produces values outside the time range of `x`. The
|
169 |
+
shaded areas on the left and the right indicate border effects caused
|
170 |
+
by the window slices in that area not fully being inside time range of
|
171 |
+
`x`:
|
172 |
+
|
173 |
+
>>> fig1, ax1 = plt.subplots(figsize=(6., 4.)) # enlarge plot a bit
|
174 |
+
>>> t_lo, t_hi = SFT.extent(N)[:2] # time range of plot
|
175 |
+
>>> ax1.set_title(rf"STFT ({SFT.m_num*SFT.T:g}$\,s$ Gaussian window, " +
|
176 |
+
... rf"$\sigma_t={g_std*SFT.T}\,$s)")
|
177 |
+
>>> ax1.set(xlabel=f"Time $t$ in seconds ({SFT.p_num(N)} slices, " +
|
178 |
+
... rf"$\Delta t = {SFT.delta_t:g}\,$s)",
|
179 |
+
... ylabel=f"Freq. $f$ in Hz ({SFT.f_pts} bins, " +
|
180 |
+
... rf"$\Delta f = {SFT.delta_f:g}\,$Hz)",
|
181 |
+
... xlim=(t_lo, t_hi))
|
182 |
+
...
|
183 |
+
>>> im1 = ax1.imshow(abs(Sx), origin='lower', aspect='auto',
|
184 |
+
... extent=SFT.extent(N), cmap='viridis')
|
185 |
+
>>> ax1.plot(t_x, f_i, 'r--', alpha=.5, label='$f_i(t)$')
|
186 |
+
>>> fig1.colorbar(im1, label="Magnitude $|S_x(t, f)|$")
|
187 |
+
...
|
188 |
+
>>> # Shade areas where window slices stick out to the side:
|
189 |
+
>>> for t0_, t1_ in [(t_lo, SFT.lower_border_end[0] * SFT.T),
|
190 |
+
... (SFT.upper_border_begin(N)[0] * SFT.T, t_hi)]:
|
191 |
+
... ax1.axvspan(t0_, t1_, color='w', linewidth=0, alpha=.2)
|
192 |
+
>>> for t_ in [0, N * SFT.T]: # mark signal borders with vertical line:
|
193 |
+
... ax1.axvline(t_, color='y', linestyle='--', alpha=0.5)
|
194 |
+
>>> ax1.legend()
|
195 |
+
>>> fig1.tight_layout()
|
196 |
+
>>> plt.show()
|
197 |
+
|
198 |
+
Reconstructing the signal with the `~ShortTimeFFT.istft` is
|
199 |
+
straightforward, but note that the length of `x1` should be specified,
|
200 |
+
since the SFT length increases in `hop` steps:
|
201 |
+
|
202 |
+
>>> SFT.invertible # check if invertible
|
203 |
+
True
|
204 |
+
>>> x1 = SFT.istft(Sx, k1=N)
|
205 |
+
>>> np.allclose(x, x1)
|
206 |
+
True
|
207 |
+
|
208 |
+
It is possible to calculate the SFT of signal parts:
|
209 |
+
|
210 |
+
>>> p_q = SFT.nearest_k_p(N // 2)
|
211 |
+
>>> Sx0 = SFT.stft(x[:p_q])
|
212 |
+
>>> Sx1 = SFT.stft(x[p_q:])
|
213 |
+
|
214 |
+
When assembling sequential STFT parts together, the overlap needs to be
|
215 |
+
considered:
|
216 |
+
|
217 |
+
>>> p0_ub = SFT.upper_border_begin(p_q)[1] - SFT.p_min
|
218 |
+
>>> p1_le = SFT.lower_border_end[1] - SFT.p_min
|
219 |
+
>>> Sx01 = np.hstack((Sx0[:, :p0_ub],
|
220 |
+
... Sx0[:, p0_ub:] + Sx1[:, :p1_le],
|
221 |
+
... Sx1[:, p1_le:]))
|
222 |
+
>>> np.allclose(Sx01, Sx) # Compare with SFT of complete signal
|
223 |
+
True
|
224 |
+
|
225 |
+
It is also possible to calculate the `itsft` for signal parts:
|
226 |
+
|
227 |
+
>>> y_p = SFT.istft(Sx, N//3, N//2)
|
228 |
+
>>> np.allclose(y_p, x[N//3:N//2])
|
229 |
+
True
|
230 |
+
|
231 |
+
"""
|
232 |
+
# immutable attributes (only have getters but no setters):
|
233 |
+
_win: np.ndarray # window
|
234 |
+
_dual_win: np.ndarray | None = None # canonical dual window
|
235 |
+
_hop: int # Step of STFT in number of samples
|
236 |
+
|
237 |
+
# mutable attributes:
|
238 |
+
_fs: float # sampling frequency of input signal and window
|
239 |
+
_fft_mode: FFT_MODE_TYPE = 'onesided' # Mode of FFT to use
|
240 |
+
_mfft: int # length of FFT used - defaults to len(win)
|
241 |
+
_scaling: Literal['magnitude', 'psd'] | None = None # Scaling of _win
|
242 |
+
_phase_shift: int | None # amount to shift phase of FFT in samples
|
243 |
+
|
244 |
+
# attributes for caching calculated values:
|
245 |
+
_fac_mag: float | None = None
|
246 |
+
_fac_psd: float | None = None
|
247 |
+
_lower_border_end: tuple[int, int] | None = None
|
248 |
+
|
249 |
+
def __init__(self, win: np.ndarray, hop: int, fs: float, *,
|
250 |
+
fft_mode: FFT_MODE_TYPE = 'onesided',
|
251 |
+
mfft: int | None = None,
|
252 |
+
dual_win: np.ndarray | None = None,
|
253 |
+
scale_to: Literal['magnitude', 'psd'] | None = None,
|
254 |
+
phase_shift: int | None = 0):
|
255 |
+
if not (win.ndim == 1 and win.size > 0):
|
256 |
+
raise ValueError(f"Parameter win must be 1d, but {win.shape=}!")
|
257 |
+
if not all(np.isfinite(win)):
|
258 |
+
raise ValueError("Parameter win must have finite entries!")
|
259 |
+
if not (hop >= 1 and isinstance(hop, int)):
|
260 |
+
raise ValueError(f"Parameter {hop=} is not an integer >= 1!")
|
261 |
+
self._win, self._hop, self.fs = win, hop, fs
|
262 |
+
|
263 |
+
self.mfft = len(win) if mfft is None else mfft
|
264 |
+
|
265 |
+
if dual_win is not None:
|
266 |
+
if dual_win.shape != win.shape:
|
267 |
+
raise ValueError(f"{dual_win.shape=} must equal {win.shape=}!")
|
268 |
+
if not all(np.isfinite(dual_win)):
|
269 |
+
raise ValueError("Parameter dual_win must be a finite array!")
|
270 |
+
self._dual_win = dual_win # needs to be set before scaling
|
271 |
+
|
272 |
+
if scale_to is not None: # needs to be set before fft_mode
|
273 |
+
self.scale_to(scale_to)
|
274 |
+
|
275 |
+
self.fft_mode, self.phase_shift = fft_mode, phase_shift
|
276 |
+
|
277 |
+
@classmethod
|
278 |
+
def from_dual(cls, dual_win: np.ndarray, hop: int, fs: float, *,
|
279 |
+
fft_mode: FFT_MODE_TYPE = 'onesided',
|
280 |
+
mfft: int | None = None,
|
281 |
+
scale_to: Literal['magnitude', 'psd'] | None = None,
|
282 |
+
phase_shift: int | None = 0):
|
283 |
+
r"""Instantiate a `ShortTimeFFT` by only providing a dual window.
|
284 |
+
|
285 |
+
If an STFT is invertible, it is possible to calculate the window `win`
|
286 |
+
from a given dual window `dual_win`. All other parameters have the
|
287 |
+
same meaning as in the initializer of `ShortTimeFFT`.
|
288 |
+
|
289 |
+
As explained in the :ref:`tutorial_stft` section of the
|
290 |
+
:ref:`user_guide`, an invertible STFT can be interpreted as series
|
291 |
+
expansion of time-shifted and frequency modulated dual windows. E.g.,
|
292 |
+
the series coefficient S[q,p] belongs to the term, which shifted
|
293 |
+
`dual_win` by p * `delta_t` and multiplied it by
|
294 |
+
exp( 2 * j * pi * t * q * `delta_f`).
|
295 |
+
|
296 |
+
|
297 |
+
Examples
|
298 |
+
--------
|
299 |
+
The following example discusses decomposing a signal into time- and
|
300 |
+
frequency-shifted Gaussians. A Gaussian with standard deviation of
|
301 |
+
one made up of 51 samples will be used:
|
302 |
+
|
303 |
+
>>> import numpy as np
|
304 |
+
>>> import matplotlib.pyplot as plt
|
305 |
+
>>> from scipy.signal import ShortTimeFFT
|
306 |
+
>>> from scipy.signal.windows import gaussian
|
307 |
+
...
|
308 |
+
>>> T, N = 0.1, 51
|
309 |
+
>>> d_win = gaussian(N, std=1/T, sym=True) # symmetric Gaussian window
|
310 |
+
>>> t = T * (np.arange(N) - N//2)
|
311 |
+
...
|
312 |
+
>>> fg1, ax1 = plt.subplots()
|
313 |
+
>>> ax1.set_title(r"Dual Window: Gaussian with $\sigma_t=1$")
|
314 |
+
>>> ax1.set(xlabel=f"Time $t$ in seconds ({N} samples, $T={T}$ s)",
|
315 |
+
... xlim=(t[0], t[-1]), ylim=(0, 1.1*max(d_win)))
|
316 |
+
>>> ax1.plot(t, d_win, 'C0-')
|
317 |
+
|
318 |
+
The following plot with the overlap of 41, 11 and 2 samples show how
|
319 |
+
the `hop` interval affects the shape of the window `win`:
|
320 |
+
|
321 |
+
>>> fig2, axx = plt.subplots(3, 1, sharex='all')
|
322 |
+
...
|
323 |
+
>>> axx[0].set_title(r"Windows for hop$\in\{10, 40, 49\}$")
|
324 |
+
>>> for c_, h_ in enumerate([10, 40, 49]):
|
325 |
+
... SFT = ShortTimeFFT.from_dual(d_win, h_, 1/T)
|
326 |
+
... axx[c_].plot(t + h_ * T, SFT.win, 'k--', alpha=.3, label=None)
|
327 |
+
... axx[c_].plot(t - h_ * T, SFT.win, 'k:', alpha=.3, label=None)
|
328 |
+
... axx[c_].plot(t, SFT.win, f'C{c_+1}',
|
329 |
+
... label=r"$\Delta t=%0.1f\,$s" % SFT.delta_t)
|
330 |
+
... axx[c_].set_ylim(0, 1.1*max(SFT.win))
|
331 |
+
... axx[c_].legend(loc='center')
|
332 |
+
>>> axx[-1].set(xlabel=f"Time $t$ in seconds ({N} samples, $T={T}$ s)",
|
333 |
+
... xlim=(t[0], t[-1]))
|
334 |
+
>>> plt.show()
|
335 |
+
|
336 |
+
Beside the window `win` centered at t = 0 the previous (t = -`delta_t`)
|
337 |
+
and following window (t = `delta_t`) are depicted. It can be seen that
|
338 |
+
for small `hop` intervals, the window is compact and smooth, having a
|
339 |
+
good time-frequency concentration in the STFT. For the large `hop`
|
340 |
+
interval of 4.9 s, the window has small values around t = 0, which are
|
341 |
+
not covered by the overlap of the adjacent windows, which could lead to
|
342 |
+
numeric inaccuracies. Furthermore, the peaky shape at the beginning and
|
343 |
+
the end of the window points to a higher bandwidth, resulting in a
|
344 |
+
poorer time-frequency resolution of the STFT.
|
345 |
+
Hence, the choice of the `hop` interval will be a compromise between
|
346 |
+
a time-frequency resolution and memory requirements demanded by small
|
347 |
+
`hop` sizes.
|
348 |
+
|
349 |
+
See Also
|
350 |
+
--------
|
351 |
+
from_window: Create instance by wrapping `get_window`.
|
352 |
+
ShortTimeFFT: Create instance using standard initializer.
|
353 |
+
"""
|
354 |
+
win = _calc_dual_canonical_window(dual_win, hop)
|
355 |
+
return cls(win=win, hop=hop, fs=fs, fft_mode=fft_mode, mfft=mfft,
|
356 |
+
dual_win=dual_win, scale_to=scale_to,
|
357 |
+
phase_shift=phase_shift)
|
358 |
+
|
359 |
+
@classmethod
|
360 |
+
def from_window(cls, win_param: str | tuple | float,
|
361 |
+
fs: float, nperseg: int, noverlap: int, *,
|
362 |
+
symmetric_win: bool = False,
|
363 |
+
fft_mode: FFT_MODE_TYPE = 'onesided',
|
364 |
+
mfft: int | None = None,
|
365 |
+
scale_to: Literal['magnitude', 'psd'] | None = None,
|
366 |
+
phase_shift: int | None = 0):
|
367 |
+
"""Instantiate `ShortTimeFFT` by using `get_window`.
|
368 |
+
|
369 |
+
The method `get_window` is used to create a window of length
|
370 |
+
`nperseg`. The parameter names `noverlap`, and `nperseg` are used here,
|
371 |
+
since they more inline with other classical STFT libraries.
|
372 |
+
|
373 |
+
Parameters
|
374 |
+
----------
|
375 |
+
win_param: Union[str, tuple, float],
|
376 |
+
Parameters passed to `get_window`. For windows with no parameters,
|
377 |
+
it may be a string (e.g., ``'hann'``), for parametrized windows a
|
378 |
+
tuple, (e.g., ``('gaussian', 2.)``) or a single float specifying
|
379 |
+
the shape parameter of a kaiser window (i.e. ``4.`` and
|
380 |
+
``('kaiser', 4.)`` are equal. See `get_window` for more details.
|
381 |
+
fs : float
|
382 |
+
Sampling frequency of input signal. Its relation to the
|
383 |
+
sampling interval `T` is ``T = 1 / fs``.
|
384 |
+
nperseg: int
|
385 |
+
Window length in samples, which corresponds to the `m_num`.
|
386 |
+
noverlap: int
|
387 |
+
Window overlap in samples. It relates to the `hop` increment by
|
388 |
+
``hop = npsereg - noverlap``.
|
389 |
+
symmetric_win: bool
|
390 |
+
If ``True`` then a symmetric window is generated, else a periodic
|
391 |
+
window is generated (default). Though symmetric windows seem for
|
392 |
+
most applications to be more sensible, the default of a periodic
|
393 |
+
windows was chosen to correspond to the default of `get_window`.
|
394 |
+
fft_mode : 'twosided', 'centered', 'onesided', 'onesided2X'
|
395 |
+
Mode of FFT to be used (default 'onesided').
|
396 |
+
See property `fft_mode` for details.
|
397 |
+
mfft: int | None
|
398 |
+
Length of the FFT used, if a zero padded FFT is desired.
|
399 |
+
If ``None`` (default), the length of the window `win` is used.
|
400 |
+
scale_to : 'magnitude', 'psd' | None
|
401 |
+
If not ``None`` (default) the window function is scaled, so each
|
402 |
+
STFT column represents either a 'magnitude' or a power spectral
|
403 |
+
density ('psd') spectrum. This parameter sets the property
|
404 |
+
`scaling` to the same value. See method `scale_to` for details.
|
405 |
+
phase_shift : int | None
|
406 |
+
If set, add a linear phase `phase_shift` / `mfft` * `f` to each
|
407 |
+
frequency `f`. The default value 0 ensures that there is no phase
|
408 |
+
shift on the zeroth slice (in which t=0 is centered). See property
|
409 |
+
`phase_shift` for more details.
|
410 |
+
|
411 |
+
Examples
|
412 |
+
--------
|
413 |
+
The following instances ``SFT0`` and ``SFT1`` are equivalent:
|
414 |
+
|
415 |
+
>>> from scipy.signal import ShortTimeFFT, get_window
|
416 |
+
>>> nperseg = 9 # window length
|
417 |
+
>>> w = get_window(('gaussian', 2.), nperseg)
|
418 |
+
>>> fs = 128 # sampling frequency
|
419 |
+
>>> hop = 3 # increment of STFT time slice
|
420 |
+
>>> SFT0 = ShortTimeFFT(w, hop, fs=fs)
|
421 |
+
>>> SFT1 = ShortTimeFFT.from_window(('gaussian', 2.), fs, nperseg,
|
422 |
+
... noverlap=nperseg-hop)
|
423 |
+
|
424 |
+
See Also
|
425 |
+
--------
|
426 |
+
scipy.signal.get_window: Return a window of a given length and type.
|
427 |
+
from_dual: Create instance using dual window.
|
428 |
+
ShortTimeFFT: Create instance using standard initializer.
|
429 |
+
"""
|
430 |
+
win = get_window(win_param, nperseg, fftbins=not symmetric_win)
|
431 |
+
return cls(win, hop=nperseg-noverlap, fs=fs, fft_mode=fft_mode,
|
432 |
+
mfft=mfft, scale_to=scale_to, phase_shift=phase_shift)
|
433 |
+
|
434 |
+
@property
|
435 |
+
def win(self) -> np.ndarray:
|
436 |
+
"""Window function as real- or complex-valued 1d array.
|
437 |
+
|
438 |
+
This attribute is read only, since `dual_win` depends on it.
|
439 |
+
|
440 |
+
See Also
|
441 |
+
--------
|
442 |
+
dual_win: Canonical dual window.
|
443 |
+
m_num: Number of samples in window `win`.
|
444 |
+
m_num_mid: Center index of window `win`.
|
445 |
+
mfft: Length of input for the FFT used - may be larger than `m_num`.
|
446 |
+
hop: ime increment in signal samples for sliding window.
|
447 |
+
win: Window function as real- or complex-valued 1d array.
|
448 |
+
ShortTimeFFT: Class this property belongs to.
|
449 |
+
"""
|
450 |
+
return self._win
|
451 |
+
|
452 |
+
@property
|
453 |
+
def hop(self) -> int:
|
454 |
+
"""Time increment in signal samples for sliding window.
|
455 |
+
|
456 |
+
This attribute is read only, since `dual_win` depends on it.
|
457 |
+
|
458 |
+
See Also
|
459 |
+
--------
|
460 |
+
delta_t: Time increment of STFT (``hop*T``)
|
461 |
+
m_num: Number of samples in window `win`.
|
462 |
+
m_num_mid: Center index of window `win`.
|
463 |
+
mfft: Length of input for the FFT used - may be larger than `m_num`.
|
464 |
+
T: Sampling interval of input signal and of the window.
|
465 |
+
win: Window function as real- or complex-valued 1d array.
|
466 |
+
ShortTimeFFT: Class this property belongs to.
|
467 |
+
"""
|
468 |
+
return self._hop
|
469 |
+
|
470 |
+
@property
|
471 |
+
def T(self) -> float:
|
472 |
+
"""Sampling interval of input signal and of the window.
|
473 |
+
|
474 |
+
A ``ValueError`` is raised if it is set to a non-positive value.
|
475 |
+
|
476 |
+
See Also
|
477 |
+
--------
|
478 |
+
delta_t: Time increment of STFT (``hop*T``)
|
479 |
+
hop: Time increment in signal samples for sliding window.
|
480 |
+
fs: Sampling frequency (being ``1/T``)
|
481 |
+
t: Times of STFT for an input signal with `n` samples.
|
482 |
+
ShortTimeFFT: Class this property belongs to.
|
483 |
+
"""
|
484 |
+
return 1 / self._fs
|
485 |
+
|
486 |
+
@T.setter
|
487 |
+
def T(self, v: float):
|
488 |
+
"""Sampling interval of input signal and of the window.
|
489 |
+
|
490 |
+
A ``ValueError`` is raised if it is set to a non-positive value.
|
491 |
+
"""
|
492 |
+
if not (v > 0):
|
493 |
+
raise ValueError(f"Sampling interval T={v} must be positive!")
|
494 |
+
self._fs = 1 / v
|
495 |
+
|
496 |
+
@property
|
497 |
+
def fs(self) -> float:
|
498 |
+
"""Sampling frequency of input signal and of the window.
|
499 |
+
|
500 |
+
The sampling frequency is the inverse of the sampling interval `T`.
|
501 |
+
A ``ValueError`` is raised if it is set to a non-positive value.
|
502 |
+
|
503 |
+
See Also
|
504 |
+
--------
|
505 |
+
delta_t: Time increment of STFT (``hop*T``)
|
506 |
+
hop: Time increment in signal samples for sliding window.
|
507 |
+
T: Sampling interval of input signal and of the window (``1/fs``).
|
508 |
+
ShortTimeFFT: Class this property belongs to.
|
509 |
+
"""
|
510 |
+
return self._fs
|
511 |
+
|
512 |
+
@fs.setter
|
513 |
+
def fs(self, v: float):
|
514 |
+
"""Sampling frequency of input signal and of the window.
|
515 |
+
|
516 |
+
The sampling frequency is the inverse of the sampling interval `T`.
|
517 |
+
A ``ValueError`` is raised if it is set to a non-positive value.
|
518 |
+
"""
|
519 |
+
if not (v > 0):
|
520 |
+
raise ValueError(f"Sampling frequency fs={v} must be positive!")
|
521 |
+
self._fs = v
|
522 |
+
|
523 |
+
@property
|
524 |
+
def fft_mode(self) -> FFT_MODE_TYPE:
|
525 |
+
"""Mode of utilized FFT ('twosided', 'centered', 'onesided' or
|
526 |
+
'onesided2X').
|
527 |
+
|
528 |
+
It can have the following values:
|
529 |
+
|
530 |
+
'twosided':
|
531 |
+
Two-sided FFT, where values for the negative frequencies are in
|
532 |
+
upper half of the array. Corresponds to :func:`~scipy.fft.fft()`.
|
533 |
+
'centered':
|
534 |
+
Two-sided FFT with the values being ordered along monotonically
|
535 |
+
increasing frequencies. Corresponds to applying
|
536 |
+
:func:`~scipy.fft.fftshift()` to :func:`~scipy.fft.fft()`.
|
537 |
+
'onesided':
|
538 |
+
Calculates only values for non-negative frequency values.
|
539 |
+
Corresponds to :func:`~scipy.fft.rfft()`.
|
540 |
+
'onesided2X':
|
541 |
+
Like `onesided`, but the non-zero frequencies are doubled if
|
542 |
+
`scaling` is set to 'magnitude' or multiplied by ``sqrt(2)`` if
|
543 |
+
set to 'psd'. If `scaling` is ``None``, setting `fft_mode` to
|
544 |
+
`onesided2X` is not allowed.
|
545 |
+
If the FFT length `mfft` is even, the last FFT value is not paired,
|
546 |
+
and thus it is not scaled.
|
547 |
+
|
548 |
+
Note that `onesided` and `onesided2X` do not work for complex-valued signals or
|
549 |
+
complex-valued windows. Furthermore, the frequency values can be obtained by
|
550 |
+
reading the `f` property, and the number of samples by accessing the `f_pts`
|
551 |
+
property.
|
552 |
+
|
553 |
+
See Also
|
554 |
+
--------
|
555 |
+
delta_f: Width of the frequency bins of the STFT.
|
556 |
+
f: Frequencies values of the STFT.
|
557 |
+
f_pts: Width of the frequency bins of the STFT.
|
558 |
+
onesided_fft: True if a one-sided FFT is used.
|
559 |
+
scaling: Normalization applied to the window function
|
560 |
+
ShortTimeFFT: Class this property belongs to.
|
561 |
+
"""
|
562 |
+
return self._fft_mode
|
563 |
+
|
564 |
+
@fft_mode.setter
|
565 |
+
def fft_mode(self, t: FFT_MODE_TYPE):
|
566 |
+
"""Set mode of FFT.
|
567 |
+
|
568 |
+
Allowed values are 'twosided', 'centered', 'onesided', 'onesided2X'.
|
569 |
+
See the property `fft_mode` for more details.
|
570 |
+
"""
|
571 |
+
if t not in (fft_mode_types := get_args(FFT_MODE_TYPE)):
|
572 |
+
raise ValueError(f"fft_mode='{t}' not in {fft_mode_types}!")
|
573 |
+
|
574 |
+
if t in {'onesided', 'onesided2X'} and np.iscomplexobj(self.win):
|
575 |
+
raise ValueError(f"One-sided spectra, i.e., fft_mode='{t}', " +
|
576 |
+
"are not allowed for complex-valued windows!")
|
577 |
+
|
578 |
+
if t == 'onesided2X' and self.scaling is None:
|
579 |
+
raise ValueError(f"For scaling is None, fft_mode='{t}' is invalid!"
|
580 |
+
"Do scale_to('psd') or scale_to('magnitude')!")
|
581 |
+
self._fft_mode = t
|
582 |
+
|
583 |
+
@property
|
584 |
+
def mfft(self) -> int:
|
585 |
+
"""Length of input for the FFT used - may be larger than window
|
586 |
+
length `m_num`.
|
587 |
+
|
588 |
+
If not set, `mfft` defaults to the window length `m_num`.
|
589 |
+
|
590 |
+
See Also
|
591 |
+
--------
|
592 |
+
f_pts: Number of points along the frequency axis.
|
593 |
+
f: Frequencies values of the STFT.
|
594 |
+
m_num: Number of samples in window `win`.
|
595 |
+
ShortTimeFFT: Class this property belongs to.
|
596 |
+
"""
|
597 |
+
return self._mfft
|
598 |
+
|
599 |
+
@mfft.setter
|
600 |
+
def mfft(self, n_: int):
|
601 |
+
"""Setter for the length of FFT utilized.
|
602 |
+
|
603 |
+
See the property `mfft` for further details.
|
604 |
+
"""
|
605 |
+
if not (n_ >= self.m_num):
|
606 |
+
raise ValueError(f"Attribute mfft={n_} needs to be at least the " +
|
607 |
+
f"window length m_num={self.m_num}!")
|
608 |
+
self._mfft = n_
|
609 |
+
|
610 |
+
@property
|
611 |
+
def scaling(self) -> Literal['magnitude', 'psd'] | None:
|
612 |
+
"""Normalization applied to the window function
|
613 |
+
('magnitude', 'psd' or ``None``).
|
614 |
+
|
615 |
+
If not ``None``, the FFTs can be either interpreted as a magnitude or
|
616 |
+
a power spectral density spectrum.
|
617 |
+
|
618 |
+
The window function can be scaled by calling the `scale_to` method,
|
619 |
+
or it is set by the initializer parameter ``scale_to``.
|
620 |
+
|
621 |
+
See Also
|
622 |
+
--------
|
623 |
+
fac_magnitude: Scaling factor for to a magnitude spectrum.
|
624 |
+
fac_psd: Scaling factor for to a power spectral density spectrum.
|
625 |
+
fft_mode: Mode of utilized FFT
|
626 |
+
scale_to: Scale window to obtain 'magnitude' or 'psd' scaling.
|
627 |
+
ShortTimeFFT: Class this property belongs to.
|
628 |
+
"""
|
629 |
+
return self._scaling
|
630 |
+
|
631 |
+
def scale_to(self, scaling: Literal['magnitude', 'psd']):
|
632 |
+
"""Scale window to obtain 'magnitude' or 'psd' scaling for the STFT.
|
633 |
+
|
634 |
+
The window of a 'magnitude' spectrum has an integral of one, i.e., unit
|
635 |
+
area for non-negative windows. This ensures that absolute the values of
|
636 |
+
spectrum does not change if the length of the window changes (given
|
637 |
+
the input signal is stationary).
|
638 |
+
|
639 |
+
To represent the power spectral density ('psd') for varying length
|
640 |
+
windows the area of the absolute square of the window needs to be
|
641 |
+
unity.
|
642 |
+
|
643 |
+
The `scaling` property shows the current scaling. The properties
|
644 |
+
`fac_magnitude` and `fac_psd` show the scaling factors required to
|
645 |
+
scale the STFT values to a magnitude or a psd spectrum.
|
646 |
+
|
647 |
+
This method is called, if the initializer parameter `scale_to` is set.
|
648 |
+
|
649 |
+
See Also
|
650 |
+
--------
|
651 |
+
fac_magnitude: Scaling factor for to a magnitude spectrum.
|
652 |
+
fac_psd: Scaling factor for to a power spectral density spectrum.
|
653 |
+
fft_mode: Mode of utilized FFT
|
654 |
+
scaling: Normalization applied to the window function.
|
655 |
+
ShortTimeFFT: Class this method belongs to.
|
656 |
+
"""
|
657 |
+
if scaling not in (scaling_values := {'magnitude', 'psd'}):
|
658 |
+
raise ValueError(f"{scaling=} not in {scaling_values}!")
|
659 |
+
if self._scaling == scaling: # do nothing
|
660 |
+
return
|
661 |
+
|
662 |
+
s_fac = self.fac_psd if scaling == 'psd' else self.fac_magnitude
|
663 |
+
self._win = self._win * s_fac
|
664 |
+
if self._dual_win is not None:
|
665 |
+
self._dual_win = self._dual_win / s_fac
|
666 |
+
self._fac_mag, self._fac_psd = None, None # reset scaling factors
|
667 |
+
self._scaling = scaling
|
668 |
+
|
669 |
+
@property
|
670 |
+
def phase_shift(self) -> int | None:
|
671 |
+
"""If set, add linear phase `phase_shift` / `mfft` * `f` to each FFT
|
672 |
+
slice of frequency `f`.
|
673 |
+
|
674 |
+
Shifting (more precisely `rolling`) an `mfft`-point FFT input by
|
675 |
+
`phase_shift` samples results in a multiplication of the output by
|
676 |
+
``np.exp(2j*np.pi*q*phase_shift/mfft)`` at the frequency q * `delta_f`.
|
677 |
+
|
678 |
+
The default value 0 ensures that there is no phase shift on the
|
679 |
+
zeroth slice (in which t=0 is centered).
|
680 |
+
No phase shift (``phase_shift is None``) is equivalent to
|
681 |
+
``phase_shift = -mfft//2``. In this case slices are not shifted
|
682 |
+
before calculating the FFT.
|
683 |
+
|
684 |
+
The absolute value of `phase_shift` is limited to be less than `mfft`.
|
685 |
+
|
686 |
+
See Also
|
687 |
+
--------
|
688 |
+
delta_f: Width of the frequency bins of the STFT.
|
689 |
+
f: Frequencies values of the STFT.
|
690 |
+
mfft: Length of input for the FFT used
|
691 |
+
ShortTimeFFT: Class this property belongs to.
|
692 |
+
"""
|
693 |
+
return self._phase_shift
|
694 |
+
|
695 |
+
@phase_shift.setter
|
696 |
+
def phase_shift(self, v: int | None):
|
697 |
+
"""The absolute value of the phase shift needs to be less than mfft
|
698 |
+
samples.
|
699 |
+
|
700 |
+
See the `phase_shift` getter method for more details.
|
701 |
+
"""
|
702 |
+
if v is None:
|
703 |
+
self._phase_shift = v
|
704 |
+
return
|
705 |
+
if not isinstance(v, int):
|
706 |
+
raise ValueError(f"phase_shift={v} has the unit samples. Hence " +
|
707 |
+
"it needs to be an int or it may be None!")
|
708 |
+
if not (-self.mfft < v < self.mfft):
|
709 |
+
raise ValueError("-mfft < phase_shift < mfft does not hold " +
|
710 |
+
f"for mfft={self.mfft}, phase_shift={v}!")
|
711 |
+
self._phase_shift = v
|
712 |
+
|
713 |
+
def _x_slices(self, x: np.ndarray, k_off: int, p0: int, p1: int,
|
714 |
+
padding: PAD_TYPE) -> Generator[np.ndarray, None, None]:
|
715 |
+
"""Generate signal slices along last axis of `x`.
|
716 |
+
|
717 |
+
This method is only used by `stft_detrend`. The parameters are
|
718 |
+
described in `~ShortTimeFFT.stft`.
|
719 |
+
"""
|
720 |
+
if padding not in (padding_types := get_args(PAD_TYPE)):
|
721 |
+
raise ValueError(f"Parameter {padding=} not in {padding_types}!")
|
722 |
+
pad_kws: dict[str, dict] = { # possible keywords to pass to np.pad:
|
723 |
+
'zeros': dict(mode='constant', constant_values=(0, 0)),
|
724 |
+
'edge': dict(mode='edge'),
|
725 |
+
'even': dict(mode='reflect', reflect_type='even'),
|
726 |
+
'odd': dict(mode='reflect', reflect_type='odd'),
|
727 |
+
} # typing of pad_kws is needed to make mypy happy
|
728 |
+
|
729 |
+
n, n1 = x.shape[-1], (p1 - p0) * self.hop
|
730 |
+
k0 = p0 * self.hop - self.m_num_mid + k_off # start sample
|
731 |
+
k1 = k0 + n1 + self.m_num # end sample
|
732 |
+
|
733 |
+
i0, i1 = max(k0, 0), min(k1, n) # indexes to shorten x
|
734 |
+
# dimensions for padding x:
|
735 |
+
pad_width = [(0, 0)] * (x.ndim-1) + [(-min(k0, 0), max(k1 - n, 0))]
|
736 |
+
|
737 |
+
x1 = np.pad(x[..., i0:i1], pad_width, **pad_kws[padding])
|
738 |
+
for k_ in range(0, n1, self.hop):
|
739 |
+
yield x1[..., k_:k_ + self.m_num]
|
740 |
+
|
741 |
+
def stft(self, x: np.ndarray, p0: int | None = None,
|
742 |
+
p1: int | None = None, *, k_offset: int = 0,
|
743 |
+
padding: PAD_TYPE = 'zeros', axis: int = -1) \
|
744 |
+
-> np.ndarray:
|
745 |
+
"""Perform the short-time Fourier transform.
|
746 |
+
|
747 |
+
A two-dimensional matrix with ``p1-p0`` columns is calculated.
|
748 |
+
The `f_pts` rows represent value at the frequencies `f`. The q-th
|
749 |
+
column of the windowed FFT with the window `win` is centered at t[q].
|
750 |
+
The columns represent the values at the frequencies `f`.
|
751 |
+
|
752 |
+
Parameters
|
753 |
+
----------
|
754 |
+
x
|
755 |
+
The input signal as real or complex valued array. For complex values, the
|
756 |
+
property `fft_mode` must be set to 'twosided' or 'centered'.
|
757 |
+
p0
|
758 |
+
The first element of the range of slices to calculate. If ``None``
|
759 |
+
then it is set to :attr:`p_min`, which is the smallest possible
|
760 |
+
slice.
|
761 |
+
p1
|
762 |
+
The end of the array. If ``None`` then `p_max(n)` is used.
|
763 |
+
k_offset
|
764 |
+
Index of first sample (t = 0) in `x`.
|
765 |
+
padding
|
766 |
+
Kind of values which are added, when the sliding window sticks out
|
767 |
+
on either the lower or upper end of the input `x`. Zeros are added
|
768 |
+
if the default 'zeros' is set. For 'edge' either the first or the
|
769 |
+
last value of `x` is used. 'even' pads by reflecting the
|
770 |
+
signal on the first or last sample and 'odd' additionally
|
771 |
+
multiplies it with -1.
|
772 |
+
axis
|
773 |
+
The axis of `x` over which to compute the STFT.
|
774 |
+
If not given, the last axis is used.
|
775 |
+
|
776 |
+
Returns
|
777 |
+
-------
|
778 |
+
S
|
779 |
+
A complex array is returned with the dimension always being larger
|
780 |
+
by one than of `x`. The last axis always represent the time slices
|
781 |
+
of the STFT. `axis` defines the frequency axis (default second to
|
782 |
+
last). E.g., for a one-dimensional `x`, a complex 2d array is
|
783 |
+
returned, with axis 0 representing frequency and axis 1 the time
|
784 |
+
slices.
|
785 |
+
|
786 |
+
See Also
|
787 |
+
--------
|
788 |
+
delta_f: Width of the frequency bins of the STFT.
|
789 |
+
delta_t: Time increment of STFT
|
790 |
+
f: Frequencies values of the STFT.
|
791 |
+
invertible: Check if STFT is invertible.
|
792 |
+
:meth:`~ShortTimeFFT.istft`: Inverse short-time Fourier transform.
|
793 |
+
p_range: Determine and validate slice index range.
|
794 |
+
stft_detrend: STFT with detrended segments.
|
795 |
+
t: Times of STFT for an input signal with `n` samples.
|
796 |
+
:class:`scipy.signal.ShortTimeFFT`: Class this method belongs to.
|
797 |
+
"""
|
798 |
+
return self.stft_detrend(x, None, p0, p1, k_offset=k_offset,
|
799 |
+
padding=padding, axis=axis)
|
800 |
+
|
801 |
+
def stft_detrend(self, x: np.ndarray,
|
802 |
+
detr: Callable[[np.ndarray], np.ndarray] | Literal['linear', 'constant'] | None, # noqa: E501
|
803 |
+
p0: int | None = None, p1: int | None = None, *,
|
804 |
+
k_offset: int = 0, padding: PAD_TYPE = 'zeros',
|
805 |
+
axis: int = -1) \
|
806 |
+
-> np.ndarray:
|
807 |
+
"""Short-time Fourier transform with a trend being subtracted from each
|
808 |
+
segment beforehand.
|
809 |
+
|
810 |
+
If `detr` is set to 'constant', the mean is subtracted, if set to
|
811 |
+
"linear", the linear trend is removed. This is achieved by calling
|
812 |
+
:func:`scipy.signal.detrend`. If `detr` is a function, `detr` is
|
813 |
+
applied to each segment.
|
814 |
+
All other parameters have the same meaning as in `~ShortTimeFFT.stft`.
|
815 |
+
|
816 |
+
Note that due to the detrending, the original signal cannot be
|
817 |
+
reconstructed by the `~ShortTimeFFT.istft`.
|
818 |
+
|
819 |
+
See Also
|
820 |
+
--------
|
821 |
+
invertible: Check if STFT is invertible.
|
822 |
+
:meth:`~ShortTimeFFT.istft`: Inverse short-time Fourier transform.
|
823 |
+
:meth:`~ShortTimeFFT.stft`: Short-time Fourier transform
|
824 |
+
(without detrending).
|
825 |
+
:class:`scipy.signal.ShortTimeFFT`: Class this method belongs to.
|
826 |
+
"""
|
827 |
+
if self.onesided_fft and np.iscomplexobj(x):
|
828 |
+
raise ValueError(f"Complex-valued `x` not allowed for {self.fft_mode=}'! "
|
829 |
+
"Set property `fft_mode` to 'twosided' or 'centered'.")
|
830 |
+
if isinstance(detr, str):
|
831 |
+
detr = partial(detrend, type=detr)
|
832 |
+
elif not (detr is None or callable(detr)):
|
833 |
+
raise ValueError(f"Parameter {detr=} is not a str, function or " +
|
834 |
+
"None!")
|
835 |
+
n = x.shape[axis]
|
836 |
+
if not (n >= (m2p := self.m_num-self.m_num_mid)):
|
837 |
+
e_str = f'{len(x)=}' if x.ndim == 1 else f'of {axis=} of {x.shape}'
|
838 |
+
raise ValueError(f"{e_str} must be >= ceil(m_num/2) = {m2p}!")
|
839 |
+
|
840 |
+
if x.ndim > 1: # motivated by the NumPy broadcasting mechanisms:
|
841 |
+
x = np.moveaxis(x, axis, -1)
|
842 |
+
# determine slice index range:
|
843 |
+
p0, p1 = self.p_range(n, p0, p1)
|
844 |
+
S_shape_1d = (self.f_pts, p1 - p0)
|
845 |
+
S_shape = x.shape[:-1] + S_shape_1d if x.ndim > 1 else S_shape_1d
|
846 |
+
S = np.zeros(S_shape, dtype=complex)
|
847 |
+
for p_, x_ in enumerate(self._x_slices(x, k_offset, p0, p1, padding)):
|
848 |
+
if detr is not None:
|
849 |
+
x_ = detr(x_)
|
850 |
+
S[..., :, p_] = self._fft_func(x_ * self.win.conj())
|
851 |
+
if x.ndim > 1:
|
852 |
+
return np.moveaxis(S, -2, axis if axis >= 0 else axis-1)
|
853 |
+
return S
|
854 |
+
|
855 |
+
def spectrogram(self, x: np.ndarray, y: np.ndarray | None = None,
|
856 |
+
detr: Callable[[np.ndarray], np.ndarray] | Literal['linear', 'constant'] | None = None, # noqa: E501
|
857 |
+
*,
|
858 |
+
p0: int | None = None, p1: int | None = None,
|
859 |
+
k_offset: int = 0, padding: PAD_TYPE = 'zeros',
|
860 |
+
axis: int = -1) \
|
861 |
+
-> np.ndarray:
|
862 |
+
r"""Calculate spectrogram or cross-spectrogram.
|
863 |
+
|
864 |
+
The spectrogram is the absolute square of the STFT, i.e, it is
|
865 |
+
``abs(S[q,p])**2`` for given ``S[q,p]`` and thus is always
|
866 |
+
non-negative.
|
867 |
+
For two STFTs ``Sx[q,p], Sy[q,p]``, the cross-spectrogram is defined
|
868 |
+
as ``Sx[q,p] * np.conj(Sx[q,p])`` and is complex-valued.
|
869 |
+
This is a convenience function for calling `~ShortTimeFFT.stft` /
|
870 |
+
`stft_detrend`, hence all parameters are discussed there. If `y` is not
|
871 |
+
``None`` it needs to have the same shape as `x`.
|
872 |
+
|
873 |
+
Examples
|
874 |
+
--------
|
875 |
+
The following example shows the spectrogram of a square wave with
|
876 |
+
varying frequency :math:`f_i(t)` (marked by a green dashed line in the
|
877 |
+
plot) sampled with 20 Hz:
|
878 |
+
|
879 |
+
>>> import matplotlib.pyplot as plt
|
880 |
+
>>> import numpy as np
|
881 |
+
>>> from scipy.signal import square, ShortTimeFFT
|
882 |
+
>>> from scipy.signal.windows import gaussian
|
883 |
+
...
|
884 |
+
>>> T_x, N = 1 / 20, 1000 # 20 Hz sampling rate for 50 s signal
|
885 |
+
>>> t_x = np.arange(N) * T_x # time indexes for signal
|
886 |
+
>>> f_i = 5e-3*(t_x - t_x[N // 3])**2 + 1 # varying frequency
|
887 |
+
>>> x = square(2*np.pi*np.cumsum(f_i)*T_x) # the signal
|
888 |
+
|
889 |
+
The utitlized Gaussian window is 50 samples or 2.5 s long. The
|
890 |
+
parameter ``mfft=800`` (oversampling factor 16) and the `hop` interval
|
891 |
+
of 2 in `ShortTimeFFT` was chosen to produce a sufficient number of
|
892 |
+
points:
|
893 |
+
|
894 |
+
>>> g_std = 12 # standard deviation for Gaussian window in samples
|
895 |
+
>>> win = gaussian(50, std=g_std, sym=True) # symmetric Gaussian wind.
|
896 |
+
>>> SFT = ShortTimeFFT(win, hop=2, fs=1/T_x, mfft=800, scale_to='psd')
|
897 |
+
>>> Sx2 = SFT.spectrogram(x) # calculate absolute square of STFT
|
898 |
+
|
899 |
+
The plot's colormap is logarithmically scaled as the power spectral
|
900 |
+
density is in dB. The time extent of the signal `x` is marked by
|
901 |
+
vertical dashed lines and the shaded areas mark the presence of border
|
902 |
+
effects:
|
903 |
+
|
904 |
+
>>> fig1, ax1 = plt.subplots(figsize=(6., 4.)) # enlarge plot a bit
|
905 |
+
>>> t_lo, t_hi = SFT.extent(N)[:2] # time range of plot
|
906 |
+
>>> ax1.set_title(rf"Spectrogram ({SFT.m_num*SFT.T:g}$\,s$ Gaussian " +
|
907 |
+
... rf"window, $\sigma_t={g_std*SFT.T:g}\,$s)")
|
908 |
+
>>> ax1.set(xlabel=f"Time $t$ in seconds ({SFT.p_num(N)} slices, " +
|
909 |
+
... rf"$\Delta t = {SFT.delta_t:g}\,$s)",
|
910 |
+
... ylabel=f"Freq. $f$ in Hz ({SFT.f_pts} bins, " +
|
911 |
+
... rf"$\Delta f = {SFT.delta_f:g}\,$Hz)",
|
912 |
+
... xlim=(t_lo, t_hi))
|
913 |
+
>>> Sx_dB = 10 * np.log10(np.fmax(Sx2, 1e-4)) # limit range to -40 dB
|
914 |
+
>>> im1 = ax1.imshow(Sx_dB, origin='lower', aspect='auto',
|
915 |
+
... extent=SFT.extent(N), cmap='magma')
|
916 |
+
>>> ax1.plot(t_x, f_i, 'g--', alpha=.5, label='$f_i(t)$')
|
917 |
+
>>> fig1.colorbar(im1, label='Power Spectral Density ' +
|
918 |
+
... r"$20\,\log_{10}|S_x(t, f)|$ in dB")
|
919 |
+
...
|
920 |
+
>>> # Shade areas where window slices stick out to the side:
|
921 |
+
>>> for t0_, t1_ in [(t_lo, SFT.lower_border_end[0] * SFT.T),
|
922 |
+
... (SFT.upper_border_begin(N)[0] * SFT.T, t_hi)]:
|
923 |
+
... ax1.axvspan(t0_, t1_, color='w', linewidth=0, alpha=.3)
|
924 |
+
>>> for t_ in [0, N * SFT.T]: # mark signal borders with vertical line
|
925 |
+
... ax1.axvline(t_, color='c', linestyle='--', alpha=0.5)
|
926 |
+
>>> ax1.legend()
|
927 |
+
>>> fig1.tight_layout()
|
928 |
+
>>> plt.show()
|
929 |
+
|
930 |
+
The logarithmic scaling reveals the odd harmonics of the square wave,
|
931 |
+
which are reflected at the Nyquist frequency of 10 Hz. This aliasing
|
932 |
+
is also the main source of the noise artifacts in the plot.
|
933 |
+
|
934 |
+
|
935 |
+
See Also
|
936 |
+
--------
|
937 |
+
:meth:`~ShortTimeFFT.stft`: Perform the short-time Fourier transform.
|
938 |
+
stft_detrend: STFT with a trend subtracted from each segment.
|
939 |
+
:class:`scipy.signal.ShortTimeFFT`: Class this method belongs to.
|
940 |
+
"""
|
941 |
+
Sx = self.stft_detrend(x, detr, p0, p1, k_offset=k_offset,
|
942 |
+
padding=padding, axis=axis)
|
943 |
+
if y is None or y is x: # do spectrogram:
|
944 |
+
return Sx.real**2 + Sx.imag**2
|
945 |
+
# Cross-spectrogram:
|
946 |
+
Sy = self.stft_detrend(y, detr, p0, p1, k_offset=k_offset,
|
947 |
+
padding=padding, axis=axis)
|
948 |
+
return Sx * Sy.conj()
|
949 |
+
|
950 |
+
@property
|
951 |
+
def dual_win(self) -> np.ndarray:
|
952 |
+
"""Canonical dual window.
|
953 |
+
|
954 |
+
A STFT can be interpreted as the input signal being expressed as a
|
955 |
+
weighted sum of modulated and time-shifted dual windows. Note that for
|
956 |
+
a given window there exist many dual windows. The canonical window is
|
957 |
+
the one with the minimal energy (i.e., :math:`L_2` norm).
|
958 |
+
|
959 |
+
`dual_win` has same length as `win`, namely `m_num` samples.
|
960 |
+
|
961 |
+
If the dual window cannot be calculated a ``ValueError`` is raised.
|
962 |
+
This attribute is read only and calculated lazily.
|
963 |
+
|
964 |
+
See Also
|
965 |
+
--------
|
966 |
+
dual_win: Canonical dual window.
|
967 |
+
m_num: Number of samples in window `win`.
|
968 |
+
win: Window function as real- or complex-valued 1d array.
|
969 |
+
ShortTimeFFT: Class this property belongs to.
|
970 |
+
"""
|
971 |
+
if self._dual_win is None:
|
972 |
+
self._dual_win = _calc_dual_canonical_window(self.win, self.hop)
|
973 |
+
return self._dual_win
|
974 |
+
|
975 |
+
@property
|
976 |
+
def invertible(self) -> bool:
|
977 |
+
"""Check if STFT is invertible.
|
978 |
+
|
979 |
+
This is achieved by trying to calculate the canonical dual window.
|
980 |
+
|
981 |
+
See Also
|
982 |
+
--------
|
983 |
+
:meth:`~ShortTimeFFT.istft`: Inverse short-time Fourier transform.
|
984 |
+
m_num: Number of samples in window `win` and `dual_win`.
|
985 |
+
dual_win: Canonical dual window.
|
986 |
+
win: Window for STFT.
|
987 |
+
ShortTimeFFT: Class this property belongs to.
|
988 |
+
"""
|
989 |
+
try:
|
990 |
+
return len(self.dual_win) > 0 # call self.dual_win()
|
991 |
+
except ValueError:
|
992 |
+
return False
|
993 |
+
|
994 |
+
def istft(self, S: np.ndarray, k0: int = 0, k1: int | None = None, *,
|
995 |
+
f_axis: int = -2, t_axis: int = -1) \
|
996 |
+
-> np.ndarray:
|
997 |
+
"""Inverse short-time Fourier transform.
|
998 |
+
|
999 |
+
It returns an array of dimension ``S.ndim - 1`` which is real
|
1000 |
+
if `onesided_fft` is set, else complex. If the STFT is not
|
1001 |
+
`invertible`, or the parameters are out of bounds a ``ValueError`` is
|
1002 |
+
raised.
|
1003 |
+
|
1004 |
+
Parameters
|
1005 |
+
----------
|
1006 |
+
S
|
1007 |
+
A complex valued array where `f_axis` denotes the frequency
|
1008 |
+
values and the `t-axis` dimension the temporal values of the
|
1009 |
+
STFT values.
|
1010 |
+
k0, k1
|
1011 |
+
The start and the end index of the reconstructed signal. The
|
1012 |
+
default (``k0 = 0``, ``k1 = None``) assumes that the maximum length
|
1013 |
+
signal should be reconstructed.
|
1014 |
+
f_axis, t_axis
|
1015 |
+
The axes in `S` denoting the frequency and the time dimension.
|
1016 |
+
|
1017 |
+
Notes
|
1018 |
+
-----
|
1019 |
+
It is required that `S` has `f_pts` entries along the `f_axis`. For
|
1020 |
+
the `t_axis` it is assumed that the first entry corresponds to
|
1021 |
+
`p_min` * `delta_t` (being <= 0). The length of `t_axis` needs to be
|
1022 |
+
compatible with `k1`. I.e., ``S.shape[t_axis] >= self.p_max(k1)`` must
|
1023 |
+
hold, if `k1` is not ``None``. Else `k1` is set to `k_max` with::
|
1024 |
+
|
1025 |
+
q_max = S.shape[t_range] + self.p_min
|
1026 |
+
k_max = (q_max - 1) * self.hop + self.m_num - self.m_num_mid
|
1027 |
+
|
1028 |
+
The :ref:`tutorial_stft` section of the :ref:`user_guide` discussed the
|
1029 |
+
slicing behavior by means of an example.
|
1030 |
+
|
1031 |
+
See Also
|
1032 |
+
--------
|
1033 |
+
invertible: Check if STFT is invertible.
|
1034 |
+
:meth:`~ShortTimeFFT.stft`: Perform Short-time Fourier transform.
|
1035 |
+
:class:`scipy.signal.ShortTimeFFT`: Class this method belongs to.
|
1036 |
+
"""
|
1037 |
+
if f_axis == t_axis:
|
1038 |
+
raise ValueError(f"{f_axis=} may not be equal to {t_axis=}!")
|
1039 |
+
if S.shape[f_axis] != self.f_pts:
|
1040 |
+
raise ValueError(f"{S.shape[f_axis]=} must be equal to " +
|
1041 |
+
f"{self.f_pts=} ({S.shape=})!")
|
1042 |
+
n_min = self.m_num-self.m_num_mid # minimum signal length
|
1043 |
+
if not (S.shape[t_axis] >= (q_num := self.p_num(n_min))):
|
1044 |
+
raise ValueError(f"{S.shape[t_axis]=} needs to have at least " +
|
1045 |
+
f"{q_num} slices ({S.shape=})!")
|
1046 |
+
if t_axis != S.ndim - 1 or f_axis != S.ndim - 2:
|
1047 |
+
t_axis = S.ndim + t_axis if t_axis < 0 else t_axis
|
1048 |
+
f_axis = S.ndim + f_axis if f_axis < 0 else f_axis
|
1049 |
+
S = np.moveaxis(S, (f_axis, t_axis), (-2, -1))
|
1050 |
+
|
1051 |
+
q_max = S.shape[-1] + self.p_min
|
1052 |
+
k_max = (q_max - 1) * self.hop + self.m_num - self.m_num_mid
|
1053 |
+
|
1054 |
+
k1 = k_max if k1 is None else k1
|
1055 |
+
if not (self.k_min <= k0 < k1 <= k_max):
|
1056 |
+
raise ValueError(f"({self.k_min=}) <= ({k0=}) < ({k1=}) <= " +
|
1057 |
+
f"({k_max=}) is false!")
|
1058 |
+
if not (num_pts := k1 - k0) >= n_min:
|
1059 |
+
raise ValueError(f"({k1=}) - ({k0=}) = {num_pts} has to be at " +
|
1060 |
+
f"least the half the window length {n_min}!")
|
1061 |
+
|
1062 |
+
q0 = (k0 // self.hop + self.p_min if k0 >= 0 else # p_min always <= 0
|
1063 |
+
k0 // self.hop)
|
1064 |
+
q1 = min(self.p_max(k1), q_max)
|
1065 |
+
k_q0, k_q1 = self.nearest_k_p(k0), self.nearest_k_p(k1, left=False)
|
1066 |
+
n_pts = k_q1 - k_q0 + self.m_num - self.m_num_mid
|
1067 |
+
x = np.zeros(S.shape[:-2] + (n_pts,),
|
1068 |
+
dtype=float if self.onesided_fft else complex)
|
1069 |
+
for q_ in range(q0, q1):
|
1070 |
+
xs = self._ifft_func(S[..., :, q_ - self.p_min]) * self.dual_win
|
1071 |
+
i0 = q_ * self.hop - self.m_num_mid
|
1072 |
+
i1 = min(i0 + self.m_num, n_pts+k0)
|
1073 |
+
j0, j1 = 0, i1 - i0
|
1074 |
+
if i0 < k0: # xs sticks out to the left on x:
|
1075 |
+
j0 += k0 - i0
|
1076 |
+
i0 = k0
|
1077 |
+
x[..., i0-k0:i1-k0] += xs[..., j0:j1]
|
1078 |
+
x = x[..., :k1-k0]
|
1079 |
+
if x.ndim > 1:
|
1080 |
+
x = np.moveaxis(x, -1, f_axis if f_axis < x.ndim else t_axis)
|
1081 |
+
return x
|
1082 |
+
|
1083 |
+
@property
|
1084 |
+
def fac_magnitude(self) -> float:
|
1085 |
+
"""Factor to multiply the STFT values by to scale each frequency slice
|
1086 |
+
to a magnitude spectrum.
|
1087 |
+
|
1088 |
+
It is 1 if attribute ``scaling == 'magnitude'``.
|
1089 |
+
The window can be scaled to a magnitude spectrum by using the method
|
1090 |
+
`scale_to`.
|
1091 |
+
|
1092 |
+
See Also
|
1093 |
+
--------
|
1094 |
+
fac_psd: Scaling factor for to a power spectral density spectrum.
|
1095 |
+
scale_to: Scale window to obtain 'magnitude' or 'psd' scaling.
|
1096 |
+
scaling: Normalization applied to the window function.
|
1097 |
+
ShortTimeFFT: Class this property belongs to.
|
1098 |
+
"""
|
1099 |
+
if self.scaling == 'magnitude':
|
1100 |
+
return 1
|
1101 |
+
if self._fac_mag is None:
|
1102 |
+
self._fac_mag = 1 / abs(sum(self.win))
|
1103 |
+
return self._fac_mag
|
1104 |
+
|
1105 |
+
@property
|
1106 |
+
def fac_psd(self) -> float:
|
1107 |
+
"""Factor to multiply the STFT values by to scale each frequency slice
|
1108 |
+
to a power spectral density (PSD).
|
1109 |
+
|
1110 |
+
It is 1 if attribute ``scaling == 'psd'``.
|
1111 |
+
The window can be scaled to a psd spectrum by using the method
|
1112 |
+
`scale_to`.
|
1113 |
+
|
1114 |
+
See Also
|
1115 |
+
--------
|
1116 |
+
fac_magnitude: Scaling factor for to a magnitude spectrum.
|
1117 |
+
scale_to: Scale window to obtain 'magnitude' or 'psd' scaling.
|
1118 |
+
scaling: Normalization applied to the window function.
|
1119 |
+
ShortTimeFFT: Class this property belongs to.
|
1120 |
+
"""
|
1121 |
+
if self.scaling == 'psd':
|
1122 |
+
return 1
|
1123 |
+
if self._fac_psd is None:
|
1124 |
+
self._fac_psd = 1 / np.sqrt(
|
1125 |
+
sum(self.win.real**2+self.win.imag**2) / self.T)
|
1126 |
+
return self._fac_psd
|
1127 |
+
|
1128 |
+
@property
|
1129 |
+
def m_num(self) -> int:
|
1130 |
+
"""Number of samples in window `win`.
|
1131 |
+
|
1132 |
+
Note that the FFT can be oversampled by zero-padding. This is achieved
|
1133 |
+
by setting the `mfft` property.
|
1134 |
+
|
1135 |
+
See Also
|
1136 |
+
--------
|
1137 |
+
m_num_mid: Center index of window `win`.
|
1138 |
+
mfft: Length of input for the FFT used - may be larger than `m_num`.
|
1139 |
+
hop: Time increment in signal samples for sliding window.
|
1140 |
+
win: Window function as real- or complex-valued 1d array.
|
1141 |
+
ShortTimeFFT: Class this property belongs to.
|
1142 |
+
"""
|
1143 |
+
return len(self.win)
|
1144 |
+
|
1145 |
+
@property
|
1146 |
+
def m_num_mid(self) -> int:
|
1147 |
+
"""Center index of window `win`.
|
1148 |
+
|
1149 |
+
For odd `m_num`, ``(m_num - 1) / 2`` is returned and
|
1150 |
+
for even `m_num` (per definition) ``m_num / 2`` is returned.
|
1151 |
+
|
1152 |
+
See Also
|
1153 |
+
--------
|
1154 |
+
m_num: Number of samples in window `win`.
|
1155 |
+
mfft: Length of input for the FFT used - may be larger than `m_num`.
|
1156 |
+
hop: ime increment in signal samples for sliding window.
|
1157 |
+
win: Window function as real- or complex-valued 1d array.
|
1158 |
+
ShortTimeFFT: Class this property belongs to.
|
1159 |
+
"""
|
1160 |
+
return self.m_num // 2
|
1161 |
+
|
1162 |
+
@cache
|
1163 |
+
def _pre_padding(self) -> tuple[int, int]:
|
1164 |
+
"""Smallest signal index and slice index due to padding.
|
1165 |
+
|
1166 |
+
Since, per convention, for time t=0, n,q is zero, the returned values
|
1167 |
+
are negative or zero.
|
1168 |
+
"""
|
1169 |
+
w2 = self.win.real**2 + self.win.imag**2
|
1170 |
+
# move window to the left until the overlap with t >= 0 vanishes:
|
1171 |
+
n0 = -self.m_num_mid
|
1172 |
+
for q_, n_ in enumerate(range(n0, n0-self.m_num-1, -self.hop)):
|
1173 |
+
n_next = n_ - self.hop
|
1174 |
+
if n_next + self.m_num <= 0 or all(w2[n_next:] == 0):
|
1175 |
+
return n_, -q_
|
1176 |
+
raise RuntimeError("This is code line should not have been reached!")
|
1177 |
+
# If this case is reached, it probably means the first slice should be
|
1178 |
+
# returned, i.e.: return n0, 0
|
1179 |
+
|
1180 |
+
@property
|
1181 |
+
def k_min(self) -> int:
|
1182 |
+
"""The smallest possible signal index of the STFT.
|
1183 |
+
|
1184 |
+
`k_min` is the index of the left-most non-zero value of the lowest
|
1185 |
+
slice `p_min`. Since the zeroth slice is centered over the zeroth
|
1186 |
+
sample of the input signal, `k_min` is never positive.
|
1187 |
+
A detailed example is provided in the :ref:`tutorial_stft_sliding_win`
|
1188 |
+
section of the :ref:`user_guide`.
|
1189 |
+
|
1190 |
+
See Also
|
1191 |
+
--------
|
1192 |
+
k_max: First sample index after signal end not touched by a time slice.
|
1193 |
+
lower_border_end: Where pre-padding effects end.
|
1194 |
+
p_min: The smallest possible slice index.
|
1195 |
+
p_max: Index of first non-overlapping upper time slice.
|
1196 |
+
p_num: Number of time slices, i.e., `p_max` - `p_min`.
|
1197 |
+
p_range: Determine and validate slice index range.
|
1198 |
+
upper_border_begin: Where post-padding effects start.
|
1199 |
+
ShortTimeFFT: Class this property belongs to.
|
1200 |
+
"""
|
1201 |
+
return self._pre_padding()[0]
|
1202 |
+
|
1203 |
+
@property
|
1204 |
+
def p_min(self) -> int:
|
1205 |
+
"""The smallest possible slice index.
|
1206 |
+
|
1207 |
+
`p_min` is the index of the left-most slice, where the window still
|
1208 |
+
sticks into the signal, i.e., has non-zero part for t >= 0.
|
1209 |
+
`k_min` is the smallest index where the window function of the slice
|
1210 |
+
`p_min` is non-zero.
|
1211 |
+
|
1212 |
+
Since, per convention the zeroth slice is centered at t=0,
|
1213 |
+
`p_min` <= 0 always holds.
|
1214 |
+
A detailed example is provided in the :ref:`tutorial_stft_sliding_win`
|
1215 |
+
section of the :ref:`user_guide`.
|
1216 |
+
|
1217 |
+
See Also
|
1218 |
+
--------
|
1219 |
+
k_min: The smallest possible signal index.
|
1220 |
+
k_max: First sample index after signal end not touched by a time slice.
|
1221 |
+
p_max: Index of first non-overlapping upper time slice.
|
1222 |
+
p_num: Number of time slices, i.e., `p_max` - `p_min`.
|
1223 |
+
p_range: Determine and validate slice index range.
|
1224 |
+
ShortTimeFFT: Class this property belongs to.
|
1225 |
+
"""
|
1226 |
+
return self._pre_padding()[1]
|
1227 |
+
|
1228 |
+
@lru_cache(maxsize=256)
|
1229 |
+
def _post_padding(self, n: int) -> tuple[int, int]:
|
1230 |
+
"""Largest signal index and slice index due to padding."""
|
1231 |
+
w2 = self.win.real**2 + self.win.imag**2
|
1232 |
+
# move window to the right until the overlap for t < t[n] vanishes:
|
1233 |
+
q1 = n // self.hop # last slice index with t[p1] <= t[n]
|
1234 |
+
k1 = q1 * self.hop - self.m_num_mid
|
1235 |
+
for q_, k_ in enumerate(range(k1, n+self.m_num, self.hop), start=q1):
|
1236 |
+
n_next = k_ + self.hop
|
1237 |
+
if n_next >= n or all(w2[:n-n_next] == 0):
|
1238 |
+
return k_ + self.m_num, q_ + 1
|
1239 |
+
raise RuntimeError("This is code line should not have been reached!")
|
1240 |
+
# If this case is reached, it probably means the last slice should be
|
1241 |
+
# returned, i.e.: return k1 + self.m_num - self.m_num_mid, q1 + 1
|
1242 |
+
|
1243 |
+
def k_max(self, n: int) -> int:
|
1244 |
+
"""First sample index after signal end not touched by a time slice.
|
1245 |
+
|
1246 |
+
`k_max` - 1 is the largest sample index of the slice `p_max` for a
|
1247 |
+
given input signal of `n` samples.
|
1248 |
+
A detailed example is provided in the :ref:`tutorial_stft_sliding_win`
|
1249 |
+
section of the :ref:`user_guide`.
|
1250 |
+
|
1251 |
+
See Also
|
1252 |
+
--------
|
1253 |
+
k_min: The smallest possible signal index.
|
1254 |
+
p_min: The smallest possible slice index.
|
1255 |
+
p_max: Index of first non-overlapping upper time slice.
|
1256 |
+
p_num: Number of time slices, i.e., `p_max` - `p_min`.
|
1257 |
+
p_range: Determine and validate slice index range.
|
1258 |
+
ShortTimeFFT: Class this method belongs to.
|
1259 |
+
"""
|
1260 |
+
return self._post_padding(n)[0]
|
1261 |
+
|
1262 |
+
def p_max(self, n: int) -> int:
|
1263 |
+
"""Index of first non-overlapping upper time slice for `n` sample
|
1264 |
+
input.
|
1265 |
+
|
1266 |
+
Note that center point t[p_max] = (p_max(n)-1) * `delta_t` is typically
|
1267 |
+
larger than last time index t[n-1] == (`n`-1) * `T`. The upper border
|
1268 |
+
of samples indexes covered by the window slices is given by `k_max`.
|
1269 |
+
Furthermore, `p_max` does not denote the number of slices `p_num` since
|
1270 |
+
`p_min` is typically less than zero.
|
1271 |
+
A detailed example is provided in the :ref:`tutorial_stft_sliding_win`
|
1272 |
+
section of the :ref:`user_guide`.
|
1273 |
+
|
1274 |
+
See Also
|
1275 |
+
--------
|
1276 |
+
k_min: The smallest possible signal index.
|
1277 |
+
k_max: First sample index after signal end not touched by a time slice.
|
1278 |
+
p_min: The smallest possible slice index.
|
1279 |
+
p_num: Number of time slices, i.e., `p_max` - `p_min`.
|
1280 |
+
p_range: Determine and validate slice index range.
|
1281 |
+
ShortTimeFFT: Class this method belongs to.
|
1282 |
+
"""
|
1283 |
+
return self._post_padding(n)[1]
|
1284 |
+
|
1285 |
+
def p_num(self, n: int) -> int:
|
1286 |
+
"""Number of time slices for an input signal with `n` samples.
|
1287 |
+
|
1288 |
+
It is given by `p_num` = `p_max` - `p_min` with `p_min` typically
|
1289 |
+
being negative.
|
1290 |
+
A detailed example is provided in the :ref:`tutorial_stft_sliding_win`
|
1291 |
+
section of the :ref:`user_guide`.
|
1292 |
+
|
1293 |
+
See Also
|
1294 |
+
--------
|
1295 |
+
k_min: The smallest possible signal index.
|
1296 |
+
k_max: First sample index after signal end not touched by a time slice.
|
1297 |
+
lower_border_end: Where pre-padding effects end.
|
1298 |
+
p_min: The smallest possible slice index.
|
1299 |
+
p_max: Index of first non-overlapping upper time slice.
|
1300 |
+
p_range: Determine and validate slice index range.
|
1301 |
+
upper_border_begin: Where post-padding effects start.
|
1302 |
+
ShortTimeFFT: Class this method belongs to.
|
1303 |
+
"""
|
1304 |
+
return self.p_max(n) - self.p_min
|
1305 |
+
|
1306 |
+
@property
|
1307 |
+
def lower_border_end(self) -> tuple[int, int]:
|
1308 |
+
"""First signal index and first slice index unaffected by pre-padding.
|
1309 |
+
|
1310 |
+
Describes the point where the window does not stick out to the left
|
1311 |
+
of the signal domain.
|
1312 |
+
A detailed example is provided in the :ref:`tutorial_stft_sliding_win`
|
1313 |
+
section of the :ref:`user_guide`.
|
1314 |
+
|
1315 |
+
See Also
|
1316 |
+
--------
|
1317 |
+
k_min: The smallest possible signal index.
|
1318 |
+
k_max: First sample index after signal end not touched by a time slice.
|
1319 |
+
lower_border_end: Where pre-padding effects end.
|
1320 |
+
p_min: The smallest possible slice index.
|
1321 |
+
p_max: Index of first non-overlapping upper time slice.
|
1322 |
+
p_num: Number of time slices, i.e., `p_max` - `p_min`.
|
1323 |
+
p_range: Determine and validate slice index range.
|
1324 |
+
upper_border_begin: Where post-padding effects start.
|
1325 |
+
ShortTimeFFT: Class this property belongs to.
|
1326 |
+
"""
|
1327 |
+
# not using @cache decorator due to MyPy limitations
|
1328 |
+
if self._lower_border_end is not None:
|
1329 |
+
return self._lower_border_end
|
1330 |
+
|
1331 |
+
# first non-zero element in self.win:
|
1332 |
+
m0 = np.flatnonzero(self.win.real**2 + self.win.imag**2)[0]
|
1333 |
+
|
1334 |
+
# move window to the right until does not stick out to the left:
|
1335 |
+
k0 = -self.m_num_mid + m0
|
1336 |
+
for q_, k_ in enumerate(range(k0, self.hop + 1, self.hop)):
|
1337 |
+
if k_ + self.hop >= 0: # next entry does not stick out anymore
|
1338 |
+
self._lower_border_end = (k_ + self.m_num, q_ + 1)
|
1339 |
+
return self._lower_border_end
|
1340 |
+
self._lower_border_end = (0, max(self.p_min, 0)) # ends at first slice
|
1341 |
+
return self._lower_border_end
|
1342 |
+
|
1343 |
+
@lru_cache(maxsize=256)
|
1344 |
+
def upper_border_begin(self, n: int) -> tuple[int, int]:
|
1345 |
+
"""First signal index and first slice index affected by post-padding.
|
1346 |
+
|
1347 |
+
Describes the point where the window does begin stick out to the right
|
1348 |
+
of the signal domain.
|
1349 |
+
A detailed example is given :ref:`tutorial_stft_sliding_win` section
|
1350 |
+
of the :ref:`user_guide`.
|
1351 |
+
|
1352 |
+
See Also
|
1353 |
+
--------
|
1354 |
+
k_min: The smallest possible signal index.
|
1355 |
+
k_max: First sample index after signal end not touched by a time slice.
|
1356 |
+
lower_border_end: Where pre-padding effects end.
|
1357 |
+
p_min: The smallest possible slice index.
|
1358 |
+
p_max: Index of first non-overlapping upper time slice.
|
1359 |
+
p_num: Number of time slices, i.e., `p_max` - `p_min`.
|
1360 |
+
p_range: Determine and validate slice index range.
|
1361 |
+
ShortTimeFFT: Class this method belongs to.
|
1362 |
+
"""
|
1363 |
+
w2 = self.win.real**2 + self.win.imag**2
|
1364 |
+
q2 = n // self.hop + 1 # first t[q] >= t[n]
|
1365 |
+
q1 = max((n-self.m_num) // self.hop - 1, -1)
|
1366 |
+
# move window left until does not stick out to the right:
|
1367 |
+
for q_ in range(q2, q1, -1):
|
1368 |
+
k_ = q_ * self.hop + (self.m_num - self.m_num_mid)
|
1369 |
+
if k_ < n or all(w2[n-k_:] == 0):
|
1370 |
+
return (q_ + 1) * self.hop - self.m_num_mid, q_ + 1
|
1371 |
+
return 0, 0 # border starts at first slice
|
1372 |
+
|
1373 |
+
@property
|
1374 |
+
def delta_t(self) -> float:
|
1375 |
+
"""Time increment of STFT.
|
1376 |
+
|
1377 |
+
The time increment `delta_t` = `T` * `hop` represents the sample
|
1378 |
+
increment `hop` converted to time based on the sampling interval `T`.
|
1379 |
+
|
1380 |
+
See Also
|
1381 |
+
--------
|
1382 |
+
delta_f: Width of the frequency bins of the STFT.
|
1383 |
+
hop: Hop size in signal samples for sliding window.
|
1384 |
+
t: Times of STFT for an input signal with `n` samples.
|
1385 |
+
T: Sampling interval of input signal and window `win`.
|
1386 |
+
ShortTimeFFT: Class this property belongs to
|
1387 |
+
"""
|
1388 |
+
return self.T * self.hop
|
1389 |
+
|
1390 |
+
def p_range(self, n: int, p0: int | None = None,
|
1391 |
+
p1: int | None = None) -> tuple[int, int]:
|
1392 |
+
"""Determine and validate slice index range.
|
1393 |
+
|
1394 |
+
Parameters
|
1395 |
+
----------
|
1396 |
+
n : int
|
1397 |
+
Number of samples of input signal, assuming t[0] = 0.
|
1398 |
+
p0 : int | None
|
1399 |
+
First slice index. If 0 then the first slice is centered at t = 0.
|
1400 |
+
If ``None`` then `p_min` is used. Note that p0 may be < 0 if
|
1401 |
+
slices are left of t = 0.
|
1402 |
+
p1 : int | None
|
1403 |
+
End of interval (last value is p1-1).
|
1404 |
+
If ``None`` then `p_max(n)` is used.
|
1405 |
+
|
1406 |
+
|
1407 |
+
Returns
|
1408 |
+
-------
|
1409 |
+
p0_ : int
|
1410 |
+
The fist slice index
|
1411 |
+
p1_ : int
|
1412 |
+
End of interval (last value is p1-1).
|
1413 |
+
|
1414 |
+
Notes
|
1415 |
+
-----
|
1416 |
+
A ``ValueError`` is raised if ``p_min <= p0 < p1 <= p_max(n)`` does not
|
1417 |
+
hold.
|
1418 |
+
|
1419 |
+
See Also
|
1420 |
+
--------
|
1421 |
+
k_min: The smallest possible signal index.
|
1422 |
+
k_max: First sample index after signal end not touched by a time slice.
|
1423 |
+
lower_border_end: Where pre-padding effects end.
|
1424 |
+
p_min: The smallest possible slice index.
|
1425 |
+
p_max: Index of first non-overlapping upper time slice.
|
1426 |
+
p_num: Number of time slices, i.e., `p_max` - `p_min`.
|
1427 |
+
upper_border_begin: Where post-padding effects start.
|
1428 |
+
ShortTimeFFT: Class this property belongs to.
|
1429 |
+
"""
|
1430 |
+
p_max = self.p_max(n) # shorthand
|
1431 |
+
p0_ = self.p_min if p0 is None else p0
|
1432 |
+
p1_ = p_max if p1 is None else p1
|
1433 |
+
if not (self.p_min <= p0_ < p1_ <= p_max):
|
1434 |
+
raise ValueError(f"Invalid Parameter {p0=}, {p1=}, i.e., " +
|
1435 |
+
f"{self.p_min=} <= p0 < p1 <= {p_max=} " +
|
1436 |
+
f"does not hold for signal length {n=}!")
|
1437 |
+
return p0_, p1_
|
1438 |
+
|
1439 |
+
@lru_cache(maxsize=1)
|
1440 |
+
def t(self, n: int, p0: int | None = None, p1: int | None = None,
|
1441 |
+
k_offset: int = 0) -> np.ndarray:
|
1442 |
+
"""Times of STFT for an input signal with `n` samples.
|
1443 |
+
|
1444 |
+
Returns a 1d array with times of the `~ShortTimeFFT.stft` values with
|
1445 |
+
the same parametrization. Note that the slices are
|
1446 |
+
``delta_t = hop * T`` time units apart.
|
1447 |
+
|
1448 |
+
Parameters
|
1449 |
+
----------
|
1450 |
+
n
|
1451 |
+
Number of sample of the input signal.
|
1452 |
+
p0
|
1453 |
+
The first element of the range of slices to calculate. If ``None``
|
1454 |
+
then it is set to :attr:`p_min`, which is the smallest possible
|
1455 |
+
slice.
|
1456 |
+
p1
|
1457 |
+
The end of the array. If ``None`` then `p_max(n)` is used.
|
1458 |
+
k_offset
|
1459 |
+
Index of first sample (t = 0) in `x`.
|
1460 |
+
|
1461 |
+
|
1462 |
+
See Also
|
1463 |
+
--------
|
1464 |
+
delta_t: Time increment of STFT (``hop*T``)
|
1465 |
+
hop: Time increment in signal samples for sliding window.
|
1466 |
+
nearest_k_p: Nearest sample index k_p for which t[k_p] == t[p] holds.
|
1467 |
+
T: Sampling interval of input signal and of the window (``1/fs``).
|
1468 |
+
fs: Sampling frequency (being ``1/T``)
|
1469 |
+
ShortTimeFFT: Class this method belongs to.
|
1470 |
+
"""
|
1471 |
+
p0, p1 = self.p_range(n, p0, p1)
|
1472 |
+
return np.arange(p0, p1) * self.delta_t + k_offset * self.T
|
1473 |
+
|
1474 |
+
def nearest_k_p(self, k: int, left: bool = True) -> int:
|
1475 |
+
"""Return nearest sample index k_p for which t[k_p] == t[p] holds.
|
1476 |
+
|
1477 |
+
The nearest next smaller time sample p (where t[p] is the center
|
1478 |
+
position of the window of the p-th slice) is p_k = k // `hop`.
|
1479 |
+
If `hop` is a divisor of `k` than `k` is returned.
|
1480 |
+
If `left` is set than p_k * `hop` is returned else (p_k+1) * `hop`.
|
1481 |
+
|
1482 |
+
This method can be used to slice an input signal into chunks for
|
1483 |
+
calculating the STFT and iSTFT incrementally.
|
1484 |
+
|
1485 |
+
See Also
|
1486 |
+
--------
|
1487 |
+
delta_t: Time increment of STFT (``hop*T``)
|
1488 |
+
hop: Time increment in signal samples for sliding window.
|
1489 |
+
T: Sampling interval of input signal and of the window (``1/fs``).
|
1490 |
+
fs: Sampling frequency (being ``1/T``)
|
1491 |
+
t: Times of STFT for an input signal with `n` samples.
|
1492 |
+
ShortTimeFFT: Class this method belongs to.
|
1493 |
+
"""
|
1494 |
+
p_q, remainder = divmod(k, self.hop)
|
1495 |
+
if remainder == 0:
|
1496 |
+
return k
|
1497 |
+
return p_q * self.hop if left else (p_q + 1) * self.hop
|
1498 |
+
|
1499 |
+
@property
|
1500 |
+
def delta_f(self) -> float:
|
1501 |
+
"""Width of the frequency bins of the STFT.
|
1502 |
+
|
1503 |
+
Return the frequency interval `delta_f` = 1 / (`mfft` * `T`).
|
1504 |
+
|
1505 |
+
See Also
|
1506 |
+
--------
|
1507 |
+
delta_t: Time increment of STFT.
|
1508 |
+
f_pts: Number of points along the frequency axis.
|
1509 |
+
f: Frequencies values of the STFT.
|
1510 |
+
mfft: Length of the input for FFT used.
|
1511 |
+
T: Sampling interval.
|
1512 |
+
t: Times of STFT for an input signal with `n` samples.
|
1513 |
+
ShortTimeFFT: Class this property belongs to.
|
1514 |
+
"""
|
1515 |
+
return 1 / (self.mfft * self.T)
|
1516 |
+
|
1517 |
+
@property
|
1518 |
+
def f_pts(self) -> int:
|
1519 |
+
"""Number of points along the frequency axis.
|
1520 |
+
|
1521 |
+
See Also
|
1522 |
+
--------
|
1523 |
+
delta_f: Width of the frequency bins of the STFT.
|
1524 |
+
f: Frequencies values of the STFT.
|
1525 |
+
mfft: Length of the input for FFT used.
|
1526 |
+
ShortTimeFFT: Class this property belongs to.
|
1527 |
+
"""
|
1528 |
+
return self.mfft // 2 + 1 if self.onesided_fft else self.mfft
|
1529 |
+
|
1530 |
+
@property
|
1531 |
+
def onesided_fft(self) -> bool:
|
1532 |
+
"""Return True if a one-sided FFT is used.
|
1533 |
+
|
1534 |
+
Returns ``True`` if `fft_mode` is either 'onesided' or 'onesided2X'.
|
1535 |
+
|
1536 |
+
See Also
|
1537 |
+
--------
|
1538 |
+
fft_mode: Utilized FFT ('twosided', 'centered', 'onesided' or
|
1539 |
+
'onesided2X')
|
1540 |
+
ShortTimeFFT: Class this property belongs to.
|
1541 |
+
"""
|
1542 |
+
return self.fft_mode in {'onesided', 'onesided2X'}
|
1543 |
+
|
1544 |
+
@property
|
1545 |
+
def f(self) -> np.ndarray:
|
1546 |
+
"""Frequencies values of the STFT.
|
1547 |
+
|
1548 |
+
A 1d array of length `f_pts` with `delta_f` spaced entries is returned.
|
1549 |
+
|
1550 |
+
See Also
|
1551 |
+
--------
|
1552 |
+
delta_f: Width of the frequency bins of the STFT.
|
1553 |
+
f_pts: Number of points along the frequency axis.
|
1554 |
+
mfft: Length of the input for FFT used.
|
1555 |
+
ShortTimeFFT: Class this property belongs to.
|
1556 |
+
"""
|
1557 |
+
if self.fft_mode in {'onesided', 'onesided2X'}:
|
1558 |
+
return fft_lib.rfftfreq(self.mfft, self.T)
|
1559 |
+
elif self.fft_mode == 'twosided':
|
1560 |
+
return fft_lib.fftfreq(self.mfft, self.T)
|
1561 |
+
elif self.fft_mode == 'centered':
|
1562 |
+
return fft_lib.fftshift(fft_lib.fftfreq(self.mfft, self.T))
|
1563 |
+
# This should never happen but makes the Linters happy:
|
1564 |
+
fft_modes = get_args(FFT_MODE_TYPE)
|
1565 |
+
raise RuntimeError(f"{self.fft_mode=} not in {fft_modes}!")
|
1566 |
+
|
1567 |
+
def _fft_func(self, x: np.ndarray) -> np.ndarray:
|
1568 |
+
"""FFT based on the `fft_mode`, `mfft`, `scaling` and `phase_shift`
|
1569 |
+
attributes.
|
1570 |
+
|
1571 |
+
For multidimensional arrays the transformation is carried out on the
|
1572 |
+
last axis.
|
1573 |
+
"""
|
1574 |
+
if self.phase_shift is not None:
|
1575 |
+
if x.shape[-1] < self.mfft: # zero pad if needed
|
1576 |
+
z_shape = list(x.shape)
|
1577 |
+
z_shape[-1] = self.mfft - x.shape[-1]
|
1578 |
+
x = np.hstack((x, np.zeros(z_shape, dtype=x.dtype)))
|
1579 |
+
p_s = (self.phase_shift + self.m_num_mid) % self.m_num
|
1580 |
+
x = np.roll(x, -p_s, axis=-1)
|
1581 |
+
|
1582 |
+
if self.fft_mode == 'twosided':
|
1583 |
+
return fft_lib.fft(x, n=self.mfft, axis=-1)
|
1584 |
+
if self.fft_mode == 'centered':
|
1585 |
+
return fft_lib.fftshift(fft_lib.fft(x, self.mfft, axis=-1), axes=-1)
|
1586 |
+
if self.fft_mode == 'onesided':
|
1587 |
+
return fft_lib.rfft(x, n=self.mfft, axis=-1)
|
1588 |
+
if self.fft_mode == 'onesided2X':
|
1589 |
+
X = fft_lib.rfft(x, n=self.mfft, axis=-1)
|
1590 |
+
# Either squared magnitude (psd) or magnitude is doubled:
|
1591 |
+
fac = np.sqrt(2) if self.scaling == 'psd' else 2
|
1592 |
+
# For even input length, the last entry is unpaired:
|
1593 |
+
X[..., 1: -1 if self.mfft % 2 == 0 else None] *= fac
|
1594 |
+
return X
|
1595 |
+
# This should never happen but makes the Linter happy:
|
1596 |
+
fft_modes = get_args(FFT_MODE_TYPE)
|
1597 |
+
raise RuntimeError(f"{self.fft_mode=} not in {fft_modes}!")
|
1598 |
+
|
1599 |
+
def _ifft_func(self, X: np.ndarray) -> np.ndarray:
|
1600 |
+
"""Inverse to `_fft_func`.
|
1601 |
+
|
1602 |
+
Returned is an array of length `m_num`. If the FFT is `onesided`
|
1603 |
+
then a float array is returned else a complex array is returned.
|
1604 |
+
For multidimensional arrays the transformation is carried out on the
|
1605 |
+
last axis.
|
1606 |
+
"""
|
1607 |
+
if self.fft_mode == 'twosided':
|
1608 |
+
x = fft_lib.ifft(X, n=self.mfft, axis=-1)
|
1609 |
+
elif self.fft_mode == 'centered':
|
1610 |
+
x = fft_lib.ifft(fft_lib.ifftshift(X, axes=-1), n=self.mfft, axis=-1)
|
1611 |
+
elif self.fft_mode == 'onesided':
|
1612 |
+
x = fft_lib.irfft(X, n=self.mfft, axis=-1)
|
1613 |
+
elif self.fft_mode == 'onesided2X':
|
1614 |
+
Xc = X.copy() # we do not want to modify function parameters
|
1615 |
+
fac = np.sqrt(2) if self.scaling == 'psd' else 2
|
1616 |
+
# For even length X the last value is not paired with a negative
|
1617 |
+
# value on the two-sided FFT:
|
1618 |
+
q1 = -1 if self.mfft % 2 == 0 else None
|
1619 |
+
Xc[..., 1:q1] /= fac
|
1620 |
+
x = fft_lib.irfft(Xc, n=self.mfft, axis=-1)
|
1621 |
+
else: # This should never happen but makes the Linter happy:
|
1622 |
+
error_str = f"{self.fft_mode=} not in {get_args(FFT_MODE_TYPE)}!"
|
1623 |
+
raise RuntimeError(error_str)
|
1624 |
+
|
1625 |
+
if self.phase_shift is None:
|
1626 |
+
return x[:self.m_num]
|
1627 |
+
p_s = (self.phase_shift + self.m_num_mid) % self.m_num
|
1628 |
+
return np.roll(x, p_s, axis=-1)[:self.m_num]
|
1629 |
+
|
1630 |
+
def extent(self, n: int, axes_seq: Literal['tf', 'ft'] = 'tf',
|
1631 |
+
center_bins: bool = False) -> tuple[float, float, float, float]:
|
1632 |
+
"""Return minimum and maximum values time-frequency values.
|
1633 |
+
|
1634 |
+
A tuple with four floats ``(t0, t1, f0, f1)`` for 'tf' and
|
1635 |
+
``(f0, f1, t0, t1)`` for 'ft' is returned describing the corners
|
1636 |
+
of the time-frequency domain of the `~ShortTimeFFT.stft`.
|
1637 |
+
That tuple can be passed to `matplotlib.pyplot.imshow` as a parameter
|
1638 |
+
with the same name.
|
1639 |
+
|
1640 |
+
Parameters
|
1641 |
+
----------
|
1642 |
+
n : int
|
1643 |
+
Number of samples in input signal.
|
1644 |
+
axes_seq : {'tf', 'ft'}
|
1645 |
+
Return time extent first and then frequency extent or vice-versa.
|
1646 |
+
center_bins: bool
|
1647 |
+
If set (default ``False``), the values of the time slots and
|
1648 |
+
frequency bins are moved from the side the middle. This is useful,
|
1649 |
+
when plotting the `~ShortTimeFFT.stft` values as step functions,
|
1650 |
+
i.e., with no interpolation.
|
1651 |
+
|
1652 |
+
See Also
|
1653 |
+
--------
|
1654 |
+
:func:`matplotlib.pyplot.imshow`: Display data as an image.
|
1655 |
+
:class:`scipy.signal.ShortTimeFFT`: Class this method belongs to.
|
1656 |
+
"""
|
1657 |
+
if axes_seq not in ('tf', 'ft'):
|
1658 |
+
raise ValueError(f"Parameter {axes_seq=} not in ['tf', 'ft']!")
|
1659 |
+
|
1660 |
+
if self.onesided_fft:
|
1661 |
+
q0, q1 = 0, self.f_pts
|
1662 |
+
elif self.fft_mode == 'centered':
|
1663 |
+
q0 = -self.mfft // 2
|
1664 |
+
q1 = self.mfft // 2 - 1 if self.mfft % 2 == 0 else self.mfft // 2
|
1665 |
+
else:
|
1666 |
+
raise ValueError(f"Attribute fft_mode={self.fft_mode} must be " +
|
1667 |
+
"in ['centered', 'onesided', 'onesided2X']")
|
1668 |
+
|
1669 |
+
p0, p1 = self.p_min, self.p_max(n) # shorthand
|
1670 |
+
if center_bins:
|
1671 |
+
t0, t1 = self.delta_t * (p0 - 0.5), self.delta_t * (p1 - 0.5)
|
1672 |
+
f0, f1 = self.delta_f * (q0 - 0.5), self.delta_f * (q1 - 0.5)
|
1673 |
+
else:
|
1674 |
+
t0, t1 = self.delta_t * p0, self.delta_t * p1
|
1675 |
+
f0, f1 = self.delta_f * q0, self.delta_f * q1
|
1676 |
+
return (t0, t1, f0, f1) if axes_seq == 'tf' else (f0, f1, t0, t1)
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_signaltools.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_sosfilt.cpython-310-x86_64-linux-gnu.so
ADDED
Binary file (303 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_spectral_py.py
ADDED
@@ -0,0 +1,2101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Tools for spectral analysis.
|
2 |
+
"""
|
3 |
+
import numpy as np
|
4 |
+
from scipy import fft as sp_fft
|
5 |
+
from . import _signaltools
|
6 |
+
from .windows import get_window
|
7 |
+
from ._spectral import _lombscargle
|
8 |
+
from ._arraytools import const_ext, even_ext, odd_ext, zero_ext
|
9 |
+
import warnings
|
10 |
+
|
11 |
+
|
12 |
+
__all__ = ['periodogram', 'welch', 'lombscargle', 'csd', 'coherence',
|
13 |
+
'spectrogram', 'stft', 'istft', 'check_COLA', 'check_NOLA']
|
14 |
+
|
15 |
+
|
16 |
+
def lombscargle(x,
|
17 |
+
y,
|
18 |
+
freqs,
|
19 |
+
precenter=False,
|
20 |
+
normalize=False):
|
21 |
+
"""
|
22 |
+
lombscargle(x, y, freqs)
|
23 |
+
|
24 |
+
Computes the Lomb-Scargle periodogram.
|
25 |
+
|
26 |
+
The Lomb-Scargle periodogram was developed by Lomb [1]_ and further
|
27 |
+
extended by Scargle [2]_ to find, and test the significance of weak
|
28 |
+
periodic signals with uneven temporal sampling.
|
29 |
+
|
30 |
+
When *normalize* is False (default) the computed periodogram
|
31 |
+
is unnormalized, it takes the value ``(A**2) * N/4`` for a harmonic
|
32 |
+
signal with amplitude A for sufficiently large N.
|
33 |
+
|
34 |
+
When *normalize* is True the computed periodogram is normalized by
|
35 |
+
the residuals of the data around a constant reference model (at zero).
|
36 |
+
|
37 |
+
Input arrays should be 1-D and will be cast to float64.
|
38 |
+
|
39 |
+
Parameters
|
40 |
+
----------
|
41 |
+
x : array_like
|
42 |
+
Sample times.
|
43 |
+
y : array_like
|
44 |
+
Measurement values.
|
45 |
+
freqs : array_like
|
46 |
+
Angular frequencies for output periodogram.
|
47 |
+
precenter : bool, optional
|
48 |
+
Pre-center measurement values by subtracting the mean.
|
49 |
+
normalize : bool, optional
|
50 |
+
Compute normalized periodogram.
|
51 |
+
|
52 |
+
Returns
|
53 |
+
-------
|
54 |
+
pgram : array_like
|
55 |
+
Lomb-Scargle periodogram.
|
56 |
+
|
57 |
+
Raises
|
58 |
+
------
|
59 |
+
ValueError
|
60 |
+
If the input arrays `x` and `y` do not have the same shape.
|
61 |
+
|
62 |
+
See Also
|
63 |
+
--------
|
64 |
+
istft: Inverse Short Time Fourier Transform
|
65 |
+
check_COLA: Check whether the Constant OverLap Add (COLA) constraint is met
|
66 |
+
welch: Power spectral density by Welch's method
|
67 |
+
spectrogram: Spectrogram by Welch's method
|
68 |
+
csd: Cross spectral density by Welch's method
|
69 |
+
|
70 |
+
Notes
|
71 |
+
-----
|
72 |
+
This subroutine calculates the periodogram using a slightly
|
73 |
+
modified algorithm due to Townsend [3]_ which allows the
|
74 |
+
periodogram to be calculated using only a single pass through
|
75 |
+
the input arrays for each frequency.
|
76 |
+
|
77 |
+
The algorithm running time scales roughly as O(x * freqs) or O(N^2)
|
78 |
+
for a large number of samples and frequencies.
|
79 |
+
|
80 |
+
References
|
81 |
+
----------
|
82 |
+
.. [1] N.R. Lomb "Least-squares frequency analysis of unequally spaced
|
83 |
+
data", Astrophysics and Space Science, vol 39, pp. 447-462, 1976
|
84 |
+
|
85 |
+
.. [2] J.D. Scargle "Studies in astronomical time series analysis. II -
|
86 |
+
Statistical aspects of spectral analysis of unevenly spaced data",
|
87 |
+
The Astrophysical Journal, vol 263, pp. 835-853, 1982
|
88 |
+
|
89 |
+
.. [3] R.H.D. Townsend, "Fast calculation of the Lomb-Scargle
|
90 |
+
periodogram using graphics processing units.", The Astrophysical
|
91 |
+
Journal Supplement Series, vol 191, pp. 247-253, 2010
|
92 |
+
|
93 |
+
Examples
|
94 |
+
--------
|
95 |
+
>>> import numpy as np
|
96 |
+
>>> import matplotlib.pyplot as plt
|
97 |
+
>>> rng = np.random.default_rng()
|
98 |
+
|
99 |
+
First define some input parameters for the signal:
|
100 |
+
|
101 |
+
>>> A = 2.
|
102 |
+
>>> w0 = 1. # rad/sec
|
103 |
+
>>> nin = 150
|
104 |
+
>>> nout = 100000
|
105 |
+
|
106 |
+
Randomly generate sample times:
|
107 |
+
|
108 |
+
>>> x = rng.uniform(0, 10*np.pi, nin)
|
109 |
+
|
110 |
+
Plot a sine wave for the selected times:
|
111 |
+
|
112 |
+
>>> y = A * np.cos(w0*x)
|
113 |
+
|
114 |
+
Define the array of frequencies for which to compute the periodogram:
|
115 |
+
|
116 |
+
>>> w = np.linspace(0.01, 10, nout)
|
117 |
+
|
118 |
+
Calculate Lomb-Scargle periodogram:
|
119 |
+
|
120 |
+
>>> import scipy.signal as signal
|
121 |
+
>>> pgram = signal.lombscargle(x, y, w, normalize=True)
|
122 |
+
|
123 |
+
Now make a plot of the input data:
|
124 |
+
|
125 |
+
>>> fig, (ax_t, ax_w) = plt.subplots(2, 1, constrained_layout=True)
|
126 |
+
>>> ax_t.plot(x, y, 'b+')
|
127 |
+
>>> ax_t.set_xlabel('Time [s]')
|
128 |
+
|
129 |
+
Then plot the normalized periodogram:
|
130 |
+
|
131 |
+
>>> ax_w.plot(w, pgram)
|
132 |
+
>>> ax_w.set_xlabel('Angular frequency [rad/s]')
|
133 |
+
>>> ax_w.set_ylabel('Normalized amplitude')
|
134 |
+
>>> plt.show()
|
135 |
+
|
136 |
+
"""
|
137 |
+
x = np.ascontiguousarray(x, dtype=np.float64)
|
138 |
+
y = np.ascontiguousarray(y, dtype=np.float64)
|
139 |
+
freqs = np.ascontiguousarray(freqs, dtype=np.float64)
|
140 |
+
|
141 |
+
assert x.ndim == 1
|
142 |
+
assert y.ndim == 1
|
143 |
+
assert freqs.ndim == 1
|
144 |
+
|
145 |
+
if precenter:
|
146 |
+
pgram = _lombscargle(x, y - y.mean(), freqs)
|
147 |
+
else:
|
148 |
+
pgram = _lombscargle(x, y, freqs)
|
149 |
+
|
150 |
+
if normalize:
|
151 |
+
pgram *= 2 / np.dot(y, y)
|
152 |
+
|
153 |
+
return pgram
|
154 |
+
|
155 |
+
|
156 |
+
def periodogram(x, fs=1.0, window='boxcar', nfft=None, detrend='constant',
|
157 |
+
return_onesided=True, scaling='density', axis=-1):
|
158 |
+
"""
|
159 |
+
Estimate power spectral density using a periodogram.
|
160 |
+
|
161 |
+
Parameters
|
162 |
+
----------
|
163 |
+
x : array_like
|
164 |
+
Time series of measurement values
|
165 |
+
fs : float, optional
|
166 |
+
Sampling frequency of the `x` time series. Defaults to 1.0.
|
167 |
+
window : str or tuple or array_like, optional
|
168 |
+
Desired window to use. If `window` is a string or tuple, it is
|
169 |
+
passed to `get_window` to generate the window values, which are
|
170 |
+
DFT-even by default. See `get_window` for a list of windows and
|
171 |
+
required parameters. If `window` is array_like it will be used
|
172 |
+
directly as the window and its length must be equal to the length
|
173 |
+
of the axis over which the periodogram is computed. Defaults
|
174 |
+
to 'boxcar'.
|
175 |
+
nfft : int, optional
|
176 |
+
Length of the FFT used. If `None` the length of `x` will be
|
177 |
+
used.
|
178 |
+
detrend : str or function or `False`, optional
|
179 |
+
Specifies how to detrend each segment. If `detrend` is a
|
180 |
+
string, it is passed as the `type` argument to the `detrend`
|
181 |
+
function. If it is a function, it takes a segment and returns a
|
182 |
+
detrended segment. If `detrend` is `False`, no detrending is
|
183 |
+
done. Defaults to 'constant'.
|
184 |
+
return_onesided : bool, optional
|
185 |
+
If `True`, return a one-sided spectrum for real data. If
|
186 |
+
`False` return a two-sided spectrum. Defaults to `True`, but for
|
187 |
+
complex data, a two-sided spectrum is always returned.
|
188 |
+
scaling : { 'density', 'spectrum' }, optional
|
189 |
+
Selects between computing the power spectral density ('density')
|
190 |
+
where `Pxx` has units of V**2/Hz and computing the squared magnitude
|
191 |
+
spectrum ('spectrum') where `Pxx` has units of V**2, if `x`
|
192 |
+
is measured in V and `fs` is measured in Hz. Defaults to
|
193 |
+
'density'
|
194 |
+
axis : int, optional
|
195 |
+
Axis along which the periodogram is computed; the default is
|
196 |
+
over the last axis (i.e. ``axis=-1``).
|
197 |
+
|
198 |
+
Returns
|
199 |
+
-------
|
200 |
+
f : ndarray
|
201 |
+
Array of sample frequencies.
|
202 |
+
Pxx : ndarray
|
203 |
+
Power spectral density or power spectrum of `x`.
|
204 |
+
|
205 |
+
See Also
|
206 |
+
--------
|
207 |
+
welch: Estimate power spectral density using Welch's method
|
208 |
+
lombscargle: Lomb-Scargle periodogram for unevenly sampled data
|
209 |
+
|
210 |
+
Notes
|
211 |
+
-----
|
212 |
+
Consult the :ref:`tutorial_SpectralAnalysis` section of the :ref:`user_guide`
|
213 |
+
for a discussion of the scalings of the power spectral density and
|
214 |
+
the magnitude (squared) spectrum.
|
215 |
+
|
216 |
+
.. versionadded:: 0.12.0
|
217 |
+
|
218 |
+
Examples
|
219 |
+
--------
|
220 |
+
>>> import numpy as np
|
221 |
+
>>> from scipy import signal
|
222 |
+
>>> import matplotlib.pyplot as plt
|
223 |
+
>>> rng = np.random.default_rng()
|
224 |
+
|
225 |
+
Generate a test signal, a 2 Vrms sine wave at 1234 Hz, corrupted by
|
226 |
+
0.001 V**2/Hz of white noise sampled at 10 kHz.
|
227 |
+
|
228 |
+
>>> fs = 10e3
|
229 |
+
>>> N = 1e5
|
230 |
+
>>> amp = 2*np.sqrt(2)
|
231 |
+
>>> freq = 1234.0
|
232 |
+
>>> noise_power = 0.001 * fs / 2
|
233 |
+
>>> time = np.arange(N) / fs
|
234 |
+
>>> x = amp*np.sin(2*np.pi*freq*time)
|
235 |
+
>>> x += rng.normal(scale=np.sqrt(noise_power), size=time.shape)
|
236 |
+
|
237 |
+
Compute and plot the power spectral density.
|
238 |
+
|
239 |
+
>>> f, Pxx_den = signal.periodogram(x, fs)
|
240 |
+
>>> plt.semilogy(f, Pxx_den)
|
241 |
+
>>> plt.ylim([1e-7, 1e2])
|
242 |
+
>>> plt.xlabel('frequency [Hz]')
|
243 |
+
>>> plt.ylabel('PSD [V**2/Hz]')
|
244 |
+
>>> plt.show()
|
245 |
+
|
246 |
+
If we average the last half of the spectral density, to exclude the
|
247 |
+
peak, we can recover the noise power on the signal.
|
248 |
+
|
249 |
+
>>> np.mean(Pxx_den[25000:])
|
250 |
+
0.000985320699252543
|
251 |
+
|
252 |
+
Now compute and plot the power spectrum.
|
253 |
+
|
254 |
+
>>> f, Pxx_spec = signal.periodogram(x, fs, 'flattop', scaling='spectrum')
|
255 |
+
>>> plt.figure()
|
256 |
+
>>> plt.semilogy(f, np.sqrt(Pxx_spec))
|
257 |
+
>>> plt.ylim([1e-4, 1e1])
|
258 |
+
>>> plt.xlabel('frequency [Hz]')
|
259 |
+
>>> plt.ylabel('Linear spectrum [V RMS]')
|
260 |
+
>>> plt.show()
|
261 |
+
|
262 |
+
The peak height in the power spectrum is an estimate of the RMS
|
263 |
+
amplitude.
|
264 |
+
|
265 |
+
>>> np.sqrt(Pxx_spec.max())
|
266 |
+
2.0077340678640727
|
267 |
+
|
268 |
+
"""
|
269 |
+
x = np.asarray(x)
|
270 |
+
|
271 |
+
if x.size == 0:
|
272 |
+
return np.empty(x.shape), np.empty(x.shape)
|
273 |
+
|
274 |
+
if window is None:
|
275 |
+
window = 'boxcar'
|
276 |
+
|
277 |
+
if nfft is None:
|
278 |
+
nperseg = x.shape[axis]
|
279 |
+
elif nfft == x.shape[axis]:
|
280 |
+
nperseg = nfft
|
281 |
+
elif nfft > x.shape[axis]:
|
282 |
+
nperseg = x.shape[axis]
|
283 |
+
elif nfft < x.shape[axis]:
|
284 |
+
s = [np.s_[:]]*len(x.shape)
|
285 |
+
s[axis] = np.s_[:nfft]
|
286 |
+
x = x[tuple(s)]
|
287 |
+
nperseg = nfft
|
288 |
+
nfft = None
|
289 |
+
|
290 |
+
if hasattr(window, 'size'):
|
291 |
+
if window.size != nperseg:
|
292 |
+
raise ValueError('the size of the window must be the same size '
|
293 |
+
'of the input on the specified axis')
|
294 |
+
|
295 |
+
return welch(x, fs=fs, window=window, nperseg=nperseg, noverlap=0,
|
296 |
+
nfft=nfft, detrend=detrend, return_onesided=return_onesided,
|
297 |
+
scaling=scaling, axis=axis)
|
298 |
+
|
299 |
+
|
300 |
+
def welch(x, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None,
|
301 |
+
detrend='constant', return_onesided=True, scaling='density',
|
302 |
+
axis=-1, average='mean'):
|
303 |
+
r"""
|
304 |
+
Estimate power spectral density using Welch's method.
|
305 |
+
|
306 |
+
Welch's method [1]_ computes an estimate of the power spectral
|
307 |
+
density by dividing the data into overlapping segments, computing a
|
308 |
+
modified periodogram for each segment and averaging the
|
309 |
+
periodograms.
|
310 |
+
|
311 |
+
Parameters
|
312 |
+
----------
|
313 |
+
x : array_like
|
314 |
+
Time series of measurement values
|
315 |
+
fs : float, optional
|
316 |
+
Sampling frequency of the `x` time series. Defaults to 1.0.
|
317 |
+
window : str or tuple or array_like, optional
|
318 |
+
Desired window to use. If `window` is a string or tuple, it is
|
319 |
+
passed to `get_window` to generate the window values, which are
|
320 |
+
DFT-even by default. See `get_window` for a list of windows and
|
321 |
+
required parameters. If `window` is array_like it will be used
|
322 |
+
directly as the window and its length must be nperseg. Defaults
|
323 |
+
to a Hann window.
|
324 |
+
nperseg : int, optional
|
325 |
+
Length of each segment. Defaults to None, but if window is str or
|
326 |
+
tuple, is set to 256, and if window is array_like, is set to the
|
327 |
+
length of the window.
|
328 |
+
noverlap : int, optional
|
329 |
+
Number of points to overlap between segments. If `None`,
|
330 |
+
``noverlap = nperseg // 2``. Defaults to `None`.
|
331 |
+
nfft : int, optional
|
332 |
+
Length of the FFT used, if a zero padded FFT is desired. If
|
333 |
+
`None`, the FFT length is `nperseg`. Defaults to `None`.
|
334 |
+
detrend : str or function or `False`, optional
|
335 |
+
Specifies how to detrend each segment. If `detrend` is a
|
336 |
+
string, it is passed as the `type` argument to the `detrend`
|
337 |
+
function. If it is a function, it takes a segment and returns a
|
338 |
+
detrended segment. If `detrend` is `False`, no detrending is
|
339 |
+
done. Defaults to 'constant'.
|
340 |
+
return_onesided : bool, optional
|
341 |
+
If `True`, return a one-sided spectrum for real data. If
|
342 |
+
`False` return a two-sided spectrum. Defaults to `True`, but for
|
343 |
+
complex data, a two-sided spectrum is always returned.
|
344 |
+
scaling : { 'density', 'spectrum' }, optional
|
345 |
+
Selects between computing the power spectral density ('density')
|
346 |
+
where `Pxx` has units of V**2/Hz and computing the squared magnitude
|
347 |
+
spectrum ('spectrum') where `Pxx` has units of V**2, if `x`
|
348 |
+
is measured in V and `fs` is measured in Hz. Defaults to
|
349 |
+
'density'
|
350 |
+
axis : int, optional
|
351 |
+
Axis along which the periodogram is computed; the default is
|
352 |
+
over the last axis (i.e. ``axis=-1``).
|
353 |
+
average : { 'mean', 'median' }, optional
|
354 |
+
Method to use when averaging periodograms. Defaults to 'mean'.
|
355 |
+
|
356 |
+
.. versionadded:: 1.2.0
|
357 |
+
|
358 |
+
Returns
|
359 |
+
-------
|
360 |
+
f : ndarray
|
361 |
+
Array of sample frequencies.
|
362 |
+
Pxx : ndarray
|
363 |
+
Power spectral density or power spectrum of x.
|
364 |
+
|
365 |
+
See Also
|
366 |
+
--------
|
367 |
+
periodogram: Simple, optionally modified periodogram
|
368 |
+
lombscargle: Lomb-Scargle periodogram for unevenly sampled data
|
369 |
+
|
370 |
+
Notes
|
371 |
+
-----
|
372 |
+
An appropriate amount of overlap will depend on the choice of window
|
373 |
+
and on your requirements. For the default Hann window an overlap of
|
374 |
+
50% is a reasonable trade off between accurately estimating the
|
375 |
+
signal power, while not over counting any of the data. Narrower
|
376 |
+
windows may require a larger overlap.
|
377 |
+
|
378 |
+
If `noverlap` is 0, this method is equivalent to Bartlett's method
|
379 |
+
[2]_.
|
380 |
+
|
381 |
+
Consult the :ref:`tutorial_SpectralAnalysis` section of the :ref:`user_guide`
|
382 |
+
for a discussion of the scalings of the power spectral density and
|
383 |
+
the (squared) magnitude spectrum.
|
384 |
+
|
385 |
+
.. versionadded:: 0.12.0
|
386 |
+
|
387 |
+
References
|
388 |
+
----------
|
389 |
+
.. [1] P. Welch, "The use of the fast Fourier transform for the
|
390 |
+
estimation of power spectra: A method based on time averaging
|
391 |
+
over short, modified periodograms", IEEE Trans. Audio
|
392 |
+
Electroacoust. vol. 15, pp. 70-73, 1967.
|
393 |
+
.. [2] M.S. Bartlett, "Periodogram Analysis and Continuous Spectra",
|
394 |
+
Biometrika, vol. 37, pp. 1-16, 1950.
|
395 |
+
|
396 |
+
Examples
|
397 |
+
--------
|
398 |
+
>>> import numpy as np
|
399 |
+
>>> from scipy import signal
|
400 |
+
>>> import matplotlib.pyplot as plt
|
401 |
+
>>> rng = np.random.default_rng()
|
402 |
+
|
403 |
+
Generate a test signal, a 2 Vrms sine wave at 1234 Hz, corrupted by
|
404 |
+
0.001 V**2/Hz of white noise sampled at 10 kHz.
|
405 |
+
|
406 |
+
>>> fs = 10e3
|
407 |
+
>>> N = 1e5
|
408 |
+
>>> amp = 2*np.sqrt(2)
|
409 |
+
>>> freq = 1234.0
|
410 |
+
>>> noise_power = 0.001 * fs / 2
|
411 |
+
>>> time = np.arange(N) / fs
|
412 |
+
>>> x = amp*np.sin(2*np.pi*freq*time)
|
413 |
+
>>> x += rng.normal(scale=np.sqrt(noise_power), size=time.shape)
|
414 |
+
|
415 |
+
Compute and plot the power spectral density.
|
416 |
+
|
417 |
+
>>> f, Pxx_den = signal.welch(x, fs, nperseg=1024)
|
418 |
+
>>> plt.semilogy(f, Pxx_den)
|
419 |
+
>>> plt.ylim([0.5e-3, 1])
|
420 |
+
>>> plt.xlabel('frequency [Hz]')
|
421 |
+
>>> plt.ylabel('PSD [V**2/Hz]')
|
422 |
+
>>> plt.show()
|
423 |
+
|
424 |
+
If we average the last half of the spectral density, to exclude the
|
425 |
+
peak, we can recover the noise power on the signal.
|
426 |
+
|
427 |
+
>>> np.mean(Pxx_den[256:])
|
428 |
+
0.0009924865443739191
|
429 |
+
|
430 |
+
Now compute and plot the power spectrum.
|
431 |
+
|
432 |
+
>>> f, Pxx_spec = signal.welch(x, fs, 'flattop', 1024, scaling='spectrum')
|
433 |
+
>>> plt.figure()
|
434 |
+
>>> plt.semilogy(f, np.sqrt(Pxx_spec))
|
435 |
+
>>> plt.xlabel('frequency [Hz]')
|
436 |
+
>>> plt.ylabel('Linear spectrum [V RMS]')
|
437 |
+
>>> plt.show()
|
438 |
+
|
439 |
+
The peak height in the power spectrum is an estimate of the RMS
|
440 |
+
amplitude.
|
441 |
+
|
442 |
+
>>> np.sqrt(Pxx_spec.max())
|
443 |
+
2.0077340678640727
|
444 |
+
|
445 |
+
If we now introduce a discontinuity in the signal, by increasing the
|
446 |
+
amplitude of a small portion of the signal by 50, we can see the
|
447 |
+
corruption of the mean average power spectral density, but using a
|
448 |
+
median average better estimates the normal behaviour.
|
449 |
+
|
450 |
+
>>> x[int(N//2):int(N//2)+10] *= 50.
|
451 |
+
>>> f, Pxx_den = signal.welch(x, fs, nperseg=1024)
|
452 |
+
>>> f_med, Pxx_den_med = signal.welch(x, fs, nperseg=1024, average='median')
|
453 |
+
>>> plt.semilogy(f, Pxx_den, label='mean')
|
454 |
+
>>> plt.semilogy(f_med, Pxx_den_med, label='median')
|
455 |
+
>>> plt.ylim([0.5e-3, 1])
|
456 |
+
>>> plt.xlabel('frequency [Hz]')
|
457 |
+
>>> plt.ylabel('PSD [V**2/Hz]')
|
458 |
+
>>> plt.legend()
|
459 |
+
>>> plt.show()
|
460 |
+
|
461 |
+
"""
|
462 |
+
freqs, Pxx = csd(x, x, fs=fs, window=window, nperseg=nperseg,
|
463 |
+
noverlap=noverlap, nfft=nfft, detrend=detrend,
|
464 |
+
return_onesided=return_onesided, scaling=scaling,
|
465 |
+
axis=axis, average=average)
|
466 |
+
|
467 |
+
return freqs, Pxx.real
|
468 |
+
|
469 |
+
|
470 |
+
def csd(x, y, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None,
|
471 |
+
detrend='constant', return_onesided=True, scaling='density',
|
472 |
+
axis=-1, average='mean'):
|
473 |
+
r"""
|
474 |
+
Estimate the cross power spectral density, Pxy, using Welch's method.
|
475 |
+
|
476 |
+
Parameters
|
477 |
+
----------
|
478 |
+
x : array_like
|
479 |
+
Time series of measurement values
|
480 |
+
y : array_like
|
481 |
+
Time series of measurement values
|
482 |
+
fs : float, optional
|
483 |
+
Sampling frequency of the `x` and `y` time series. Defaults
|
484 |
+
to 1.0.
|
485 |
+
window : str or tuple or array_like, optional
|
486 |
+
Desired window to use. If `window` is a string or tuple, it is
|
487 |
+
passed to `get_window` to generate the window values, which are
|
488 |
+
DFT-even by default. See `get_window` for a list of windows and
|
489 |
+
required parameters. If `window` is array_like it will be used
|
490 |
+
directly as the window and its length must be nperseg. Defaults
|
491 |
+
to a Hann window.
|
492 |
+
nperseg : int, optional
|
493 |
+
Length of each segment. Defaults to None, but if window is str or
|
494 |
+
tuple, is set to 256, and if window is array_like, is set to the
|
495 |
+
length of the window.
|
496 |
+
noverlap: int, optional
|
497 |
+
Number of points to overlap between segments. If `None`,
|
498 |
+
``noverlap = nperseg // 2``. Defaults to `None`.
|
499 |
+
nfft : int, optional
|
500 |
+
Length of the FFT used, if a zero padded FFT is desired. If
|
501 |
+
`None`, the FFT length is `nperseg`. Defaults to `None`.
|
502 |
+
detrend : str or function or `False`, optional
|
503 |
+
Specifies how to detrend each segment. If `detrend` is a
|
504 |
+
string, it is passed as the `type` argument to the `detrend`
|
505 |
+
function. If it is a function, it takes a segment and returns a
|
506 |
+
detrended segment. If `detrend` is `False`, no detrending is
|
507 |
+
done. Defaults to 'constant'.
|
508 |
+
return_onesided : bool, optional
|
509 |
+
If `True`, return a one-sided spectrum for real data. If
|
510 |
+
`False` return a two-sided spectrum. Defaults to `True`, but for
|
511 |
+
complex data, a two-sided spectrum is always returned.
|
512 |
+
scaling : { 'density', 'spectrum' }, optional
|
513 |
+
Selects between computing the cross spectral density ('density')
|
514 |
+
where `Pxy` has units of V**2/Hz and computing the cross spectrum
|
515 |
+
('spectrum') where `Pxy` has units of V**2, if `x` and `y` are
|
516 |
+
measured in V and `fs` is measured in Hz. Defaults to 'density'
|
517 |
+
axis : int, optional
|
518 |
+
Axis along which the CSD is computed for both inputs; the
|
519 |
+
default is over the last axis (i.e. ``axis=-1``).
|
520 |
+
average : { 'mean', 'median' }, optional
|
521 |
+
Method to use when averaging periodograms. If the spectrum is
|
522 |
+
complex, the average is computed separately for the real and
|
523 |
+
imaginary parts. Defaults to 'mean'.
|
524 |
+
|
525 |
+
.. versionadded:: 1.2.0
|
526 |
+
|
527 |
+
Returns
|
528 |
+
-------
|
529 |
+
f : ndarray
|
530 |
+
Array of sample frequencies.
|
531 |
+
Pxy : ndarray
|
532 |
+
Cross spectral density or cross power spectrum of x,y.
|
533 |
+
|
534 |
+
See Also
|
535 |
+
--------
|
536 |
+
periodogram: Simple, optionally modified periodogram
|
537 |
+
lombscargle: Lomb-Scargle periodogram for unevenly sampled data
|
538 |
+
welch: Power spectral density by Welch's method. [Equivalent to
|
539 |
+
csd(x,x)]
|
540 |
+
coherence: Magnitude squared coherence by Welch's method.
|
541 |
+
|
542 |
+
Notes
|
543 |
+
-----
|
544 |
+
By convention, Pxy is computed with the conjugate FFT of X
|
545 |
+
multiplied by the FFT of Y.
|
546 |
+
|
547 |
+
If the input series differ in length, the shorter series will be
|
548 |
+
zero-padded to match.
|
549 |
+
|
550 |
+
An appropriate amount of overlap will depend on the choice of window
|
551 |
+
and on your requirements. For the default Hann window an overlap of
|
552 |
+
50% is a reasonable trade off between accurately estimating the
|
553 |
+
signal power, while not over counting any of the data. Narrower
|
554 |
+
windows may require a larger overlap.
|
555 |
+
|
556 |
+
Consult the :ref:`tutorial_SpectralAnalysis` section of the :ref:`user_guide`
|
557 |
+
for a discussion of the scalings of a spectral density and an (amplitude) spectrum.
|
558 |
+
|
559 |
+
.. versionadded:: 0.16.0
|
560 |
+
|
561 |
+
References
|
562 |
+
----------
|
563 |
+
.. [1] P. Welch, "The use of the fast Fourier transform for the
|
564 |
+
estimation of power spectra: A method based on time averaging
|
565 |
+
over short, modified periodograms", IEEE Trans. Audio
|
566 |
+
Electroacoust. vol. 15, pp. 70-73, 1967.
|
567 |
+
.. [2] Rabiner, Lawrence R., and B. Gold. "Theory and Application of
|
568 |
+
Digital Signal Processing" Prentice-Hall, pp. 414-419, 1975
|
569 |
+
|
570 |
+
Examples
|
571 |
+
--------
|
572 |
+
>>> import numpy as np
|
573 |
+
>>> from scipy import signal
|
574 |
+
>>> import matplotlib.pyplot as plt
|
575 |
+
>>> rng = np.random.default_rng()
|
576 |
+
|
577 |
+
Generate two test signals with some common features.
|
578 |
+
|
579 |
+
>>> fs = 10e3
|
580 |
+
>>> N = 1e5
|
581 |
+
>>> amp = 20
|
582 |
+
>>> freq = 1234.0
|
583 |
+
>>> noise_power = 0.001 * fs / 2
|
584 |
+
>>> time = np.arange(N) / fs
|
585 |
+
>>> b, a = signal.butter(2, 0.25, 'low')
|
586 |
+
>>> x = rng.normal(scale=np.sqrt(noise_power), size=time.shape)
|
587 |
+
>>> y = signal.lfilter(b, a, x)
|
588 |
+
>>> x += amp*np.sin(2*np.pi*freq*time)
|
589 |
+
>>> y += rng.normal(scale=0.1*np.sqrt(noise_power), size=time.shape)
|
590 |
+
|
591 |
+
Compute and plot the magnitude of the cross spectral density.
|
592 |
+
|
593 |
+
>>> f, Pxy = signal.csd(x, y, fs, nperseg=1024)
|
594 |
+
>>> plt.semilogy(f, np.abs(Pxy))
|
595 |
+
>>> plt.xlabel('frequency [Hz]')
|
596 |
+
>>> plt.ylabel('CSD [V**2/Hz]')
|
597 |
+
>>> plt.show()
|
598 |
+
|
599 |
+
"""
|
600 |
+
freqs, _, Pxy = _spectral_helper(x, y, fs, window, nperseg, noverlap,
|
601 |
+
nfft, detrend, return_onesided, scaling,
|
602 |
+
axis, mode='psd')
|
603 |
+
|
604 |
+
# Average over windows.
|
605 |
+
if len(Pxy.shape) >= 2 and Pxy.size > 0:
|
606 |
+
if Pxy.shape[-1] > 1:
|
607 |
+
if average == 'median':
|
608 |
+
# np.median must be passed real arrays for the desired result
|
609 |
+
bias = _median_bias(Pxy.shape[-1])
|
610 |
+
if np.iscomplexobj(Pxy):
|
611 |
+
Pxy = (np.median(np.real(Pxy), axis=-1)
|
612 |
+
+ 1j * np.median(np.imag(Pxy), axis=-1))
|
613 |
+
else:
|
614 |
+
Pxy = np.median(Pxy, axis=-1)
|
615 |
+
Pxy /= bias
|
616 |
+
elif average == 'mean':
|
617 |
+
Pxy = Pxy.mean(axis=-1)
|
618 |
+
else:
|
619 |
+
raise ValueError(f'average must be "median" or "mean", got {average}')
|
620 |
+
else:
|
621 |
+
Pxy = np.reshape(Pxy, Pxy.shape[:-1])
|
622 |
+
|
623 |
+
return freqs, Pxy
|
624 |
+
|
625 |
+
|
626 |
+
def spectrogram(x, fs=1.0, window=('tukey', .25), nperseg=None, noverlap=None,
|
627 |
+
nfft=None, detrend='constant', return_onesided=True,
|
628 |
+
scaling='density', axis=-1, mode='psd'):
|
629 |
+
"""Compute a spectrogram with consecutive Fourier transforms (legacy function).
|
630 |
+
|
631 |
+
Spectrograms can be used as a way of visualizing the change of a
|
632 |
+
nonstationary signal's frequency content over time.
|
633 |
+
|
634 |
+
.. legacy:: function
|
635 |
+
|
636 |
+
:class:`ShortTimeFFT` is a newer STFT / ISTFT implementation with more
|
637 |
+
features also including a :meth:`~ShortTimeFFT.spectrogram` method.
|
638 |
+
A :ref:`comparison <tutorial_stft_legacy_stft>` between the
|
639 |
+
implementations can be found in the :ref:`tutorial_stft` section of
|
640 |
+
the :ref:`user_guide`.
|
641 |
+
|
642 |
+
Parameters
|
643 |
+
----------
|
644 |
+
x : array_like
|
645 |
+
Time series of measurement values
|
646 |
+
fs : float, optional
|
647 |
+
Sampling frequency of the `x` time series. Defaults to 1.0.
|
648 |
+
window : str or tuple or array_like, optional
|
649 |
+
Desired window to use. If `window` is a string or tuple, it is
|
650 |
+
passed to `get_window` to generate the window values, which are
|
651 |
+
DFT-even by default. See `get_window` for a list of windows and
|
652 |
+
required parameters. If `window` is array_like it will be used
|
653 |
+
directly as the window and its length must be nperseg.
|
654 |
+
Defaults to a Tukey window with shape parameter of 0.25.
|
655 |
+
nperseg : int, optional
|
656 |
+
Length of each segment. Defaults to None, but if window is str or
|
657 |
+
tuple, is set to 256, and if window is array_like, is set to the
|
658 |
+
length of the window.
|
659 |
+
noverlap : int, optional
|
660 |
+
Number of points to overlap between segments. If `None`,
|
661 |
+
``noverlap = nperseg // 8``. Defaults to `None`.
|
662 |
+
nfft : int, optional
|
663 |
+
Length of the FFT used, if a zero padded FFT is desired. If
|
664 |
+
`None`, the FFT length is `nperseg`. Defaults to `None`.
|
665 |
+
detrend : str or function or `False`, optional
|
666 |
+
Specifies how to detrend each segment. If `detrend` is a
|
667 |
+
string, it is passed as the `type` argument to the `detrend`
|
668 |
+
function. If it is a function, it takes a segment and returns a
|
669 |
+
detrended segment. If `detrend` is `False`, no detrending is
|
670 |
+
done. Defaults to 'constant'.
|
671 |
+
return_onesided : bool, optional
|
672 |
+
If `True`, return a one-sided spectrum for real data. If
|
673 |
+
`False` return a two-sided spectrum. Defaults to `True`, but for
|
674 |
+
complex data, a two-sided spectrum is always returned.
|
675 |
+
scaling : { 'density', 'spectrum' }, optional
|
676 |
+
Selects between computing the power spectral density ('density')
|
677 |
+
where `Sxx` has units of V**2/Hz and computing the power
|
678 |
+
spectrum ('spectrum') where `Sxx` has units of V**2, if `x`
|
679 |
+
is measured in V and `fs` is measured in Hz. Defaults to
|
680 |
+
'density'.
|
681 |
+
axis : int, optional
|
682 |
+
Axis along which the spectrogram is computed; the default is over
|
683 |
+
the last axis (i.e. ``axis=-1``).
|
684 |
+
mode : str, optional
|
685 |
+
Defines what kind of return values are expected. Options are
|
686 |
+
['psd', 'complex', 'magnitude', 'angle', 'phase']. 'complex' is
|
687 |
+
equivalent to the output of `stft` with no padding or boundary
|
688 |
+
extension. 'magnitude' returns the absolute magnitude of the
|
689 |
+
STFT. 'angle' and 'phase' return the complex angle of the STFT,
|
690 |
+
with and without unwrapping, respectively.
|
691 |
+
|
692 |
+
Returns
|
693 |
+
-------
|
694 |
+
f : ndarray
|
695 |
+
Array of sample frequencies.
|
696 |
+
t : ndarray
|
697 |
+
Array of segment times.
|
698 |
+
Sxx : ndarray
|
699 |
+
Spectrogram of x. By default, the last axis of Sxx corresponds
|
700 |
+
to the segment times.
|
701 |
+
|
702 |
+
See Also
|
703 |
+
--------
|
704 |
+
periodogram: Simple, optionally modified periodogram
|
705 |
+
lombscargle: Lomb-Scargle periodogram for unevenly sampled data
|
706 |
+
welch: Power spectral density by Welch's method.
|
707 |
+
csd: Cross spectral density by Welch's method.
|
708 |
+
ShortTimeFFT: Newer STFT/ISTFT implementation providing more features,
|
709 |
+
which also includes a :meth:`~ShortTimeFFT.spectrogram`
|
710 |
+
method.
|
711 |
+
|
712 |
+
Notes
|
713 |
+
-----
|
714 |
+
An appropriate amount of overlap will depend on the choice of window
|
715 |
+
and on your requirements. In contrast to welch's method, where the
|
716 |
+
entire data stream is averaged over, one may wish to use a smaller
|
717 |
+
overlap (or perhaps none at all) when computing a spectrogram, to
|
718 |
+
maintain some statistical independence between individual segments.
|
719 |
+
It is for this reason that the default window is a Tukey window with
|
720 |
+
1/8th of a window's length overlap at each end.
|
721 |
+
|
722 |
+
|
723 |
+
.. versionadded:: 0.16.0
|
724 |
+
|
725 |
+
References
|
726 |
+
----------
|
727 |
+
.. [1] Oppenheim, Alan V., Ronald W. Schafer, John R. Buck
|
728 |
+
"Discrete-Time Signal Processing", Prentice Hall, 1999.
|
729 |
+
|
730 |
+
Examples
|
731 |
+
--------
|
732 |
+
>>> import numpy as np
|
733 |
+
>>> from scipy import signal
|
734 |
+
>>> from scipy.fft import fftshift
|
735 |
+
>>> import matplotlib.pyplot as plt
|
736 |
+
>>> rng = np.random.default_rng()
|
737 |
+
|
738 |
+
Generate a test signal, a 2 Vrms sine wave whose frequency is slowly
|
739 |
+
modulated around 3kHz, corrupted by white noise of exponentially
|
740 |
+
decreasing magnitude sampled at 10 kHz.
|
741 |
+
|
742 |
+
>>> fs = 10e3
|
743 |
+
>>> N = 1e5
|
744 |
+
>>> amp = 2 * np.sqrt(2)
|
745 |
+
>>> noise_power = 0.01 * fs / 2
|
746 |
+
>>> time = np.arange(N) / float(fs)
|
747 |
+
>>> mod = 500*np.cos(2*np.pi*0.25*time)
|
748 |
+
>>> carrier = amp * np.sin(2*np.pi*3e3*time + mod)
|
749 |
+
>>> noise = rng.normal(scale=np.sqrt(noise_power), size=time.shape)
|
750 |
+
>>> noise *= np.exp(-time/5)
|
751 |
+
>>> x = carrier + noise
|
752 |
+
|
753 |
+
Compute and plot the spectrogram.
|
754 |
+
|
755 |
+
>>> f, t, Sxx = signal.spectrogram(x, fs)
|
756 |
+
>>> plt.pcolormesh(t, f, Sxx, shading='gouraud')
|
757 |
+
>>> plt.ylabel('Frequency [Hz]')
|
758 |
+
>>> plt.xlabel('Time [sec]')
|
759 |
+
>>> plt.show()
|
760 |
+
|
761 |
+
Note, if using output that is not one sided, then use the following:
|
762 |
+
|
763 |
+
>>> f, t, Sxx = signal.spectrogram(x, fs, return_onesided=False)
|
764 |
+
>>> plt.pcolormesh(t, fftshift(f), fftshift(Sxx, axes=0), shading='gouraud')
|
765 |
+
>>> plt.ylabel('Frequency [Hz]')
|
766 |
+
>>> plt.xlabel('Time [sec]')
|
767 |
+
>>> plt.show()
|
768 |
+
|
769 |
+
"""
|
770 |
+
modelist = ['psd', 'complex', 'magnitude', 'angle', 'phase']
|
771 |
+
if mode not in modelist:
|
772 |
+
raise ValueError(f'unknown value for mode {mode}, must be one of {modelist}')
|
773 |
+
|
774 |
+
# need to set default for nperseg before setting default for noverlap below
|
775 |
+
window, nperseg = _triage_segments(window, nperseg,
|
776 |
+
input_length=x.shape[axis])
|
777 |
+
|
778 |
+
# Less overlap than welch, so samples are more statisically independent
|
779 |
+
if noverlap is None:
|
780 |
+
noverlap = nperseg // 8
|
781 |
+
|
782 |
+
if mode == 'psd':
|
783 |
+
freqs, time, Sxx = _spectral_helper(x, x, fs, window, nperseg,
|
784 |
+
noverlap, nfft, detrend,
|
785 |
+
return_onesided, scaling, axis,
|
786 |
+
mode='psd')
|
787 |
+
|
788 |
+
else:
|
789 |
+
freqs, time, Sxx = _spectral_helper(x, x, fs, window, nperseg,
|
790 |
+
noverlap, nfft, detrend,
|
791 |
+
return_onesided, scaling, axis,
|
792 |
+
mode='stft')
|
793 |
+
|
794 |
+
if mode == 'magnitude':
|
795 |
+
Sxx = np.abs(Sxx)
|
796 |
+
elif mode in ['angle', 'phase']:
|
797 |
+
Sxx = np.angle(Sxx)
|
798 |
+
if mode == 'phase':
|
799 |
+
# Sxx has one additional dimension for time strides
|
800 |
+
if axis < 0:
|
801 |
+
axis -= 1
|
802 |
+
Sxx = np.unwrap(Sxx, axis=axis)
|
803 |
+
|
804 |
+
# mode =='complex' is same as `stft`, doesn't need modification
|
805 |
+
|
806 |
+
return freqs, time, Sxx
|
807 |
+
|
808 |
+
|
809 |
+
def check_COLA(window, nperseg, noverlap, tol=1e-10):
|
810 |
+
r"""Check whether the Constant OverLap Add (COLA) constraint is met.
|
811 |
+
|
812 |
+
Parameters
|
813 |
+
----------
|
814 |
+
window : str or tuple or array_like
|
815 |
+
Desired window to use. If `window` is a string or tuple, it is
|
816 |
+
passed to `get_window` to generate the window values, which are
|
817 |
+
DFT-even by default. See `get_window` for a list of windows and
|
818 |
+
required parameters. If `window` is array_like it will be used
|
819 |
+
directly as the window and its length must be nperseg.
|
820 |
+
nperseg : int
|
821 |
+
Length of each segment.
|
822 |
+
noverlap : int
|
823 |
+
Number of points to overlap between segments.
|
824 |
+
tol : float, optional
|
825 |
+
The allowed variance of a bin's weighted sum from the median bin
|
826 |
+
sum.
|
827 |
+
|
828 |
+
Returns
|
829 |
+
-------
|
830 |
+
verdict : bool
|
831 |
+
`True` if chosen combination satisfies COLA within `tol`,
|
832 |
+
`False` otherwise
|
833 |
+
|
834 |
+
See Also
|
835 |
+
--------
|
836 |
+
check_NOLA: Check whether the Nonzero Overlap Add (NOLA) constraint is met
|
837 |
+
stft: Short Time Fourier Transform
|
838 |
+
istft: Inverse Short Time Fourier Transform
|
839 |
+
|
840 |
+
Notes
|
841 |
+
-----
|
842 |
+
In order to enable inversion of an STFT via the inverse STFT in
|
843 |
+
`istft`, it is sufficient that the signal windowing obeys the constraint of
|
844 |
+
"Constant OverLap Add" (COLA). This ensures that every point in the input
|
845 |
+
data is equally weighted, thereby avoiding aliasing and allowing full
|
846 |
+
reconstruction.
|
847 |
+
|
848 |
+
Some examples of windows that satisfy COLA:
|
849 |
+
- Rectangular window at overlap of 0, 1/2, 2/3, 3/4, ...
|
850 |
+
- Bartlett window at overlap of 1/2, 3/4, 5/6, ...
|
851 |
+
- Hann window at 1/2, 2/3, 3/4, ...
|
852 |
+
- Any Blackman family window at 2/3 overlap
|
853 |
+
- Any window with ``noverlap = nperseg-1``
|
854 |
+
|
855 |
+
A very comprehensive list of other windows may be found in [2]_,
|
856 |
+
wherein the COLA condition is satisfied when the "Amplitude
|
857 |
+
Flatness" is unity.
|
858 |
+
|
859 |
+
.. versionadded:: 0.19.0
|
860 |
+
|
861 |
+
References
|
862 |
+
----------
|
863 |
+
.. [1] Julius O. Smith III, "Spectral Audio Signal Processing", W3K
|
864 |
+
Publishing, 2011,ISBN 978-0-9745607-3-1.
|
865 |
+
.. [2] G. Heinzel, A. Ruediger and R. Schilling, "Spectrum and
|
866 |
+
spectral density estimation by the Discrete Fourier transform
|
867 |
+
(DFT), including a comprehensive list of window functions and
|
868 |
+
some new at-top windows", 2002,
|
869 |
+
http://hdl.handle.net/11858/00-001M-0000-0013-557A-5
|
870 |
+
|
871 |
+
Examples
|
872 |
+
--------
|
873 |
+
>>> from scipy import signal
|
874 |
+
|
875 |
+
Confirm COLA condition for rectangular window of 75% (3/4) overlap:
|
876 |
+
|
877 |
+
>>> signal.check_COLA(signal.windows.boxcar(100), 100, 75)
|
878 |
+
True
|
879 |
+
|
880 |
+
COLA is not true for 25% (1/4) overlap, though:
|
881 |
+
|
882 |
+
>>> signal.check_COLA(signal.windows.boxcar(100), 100, 25)
|
883 |
+
False
|
884 |
+
|
885 |
+
"Symmetrical" Hann window (for filter design) is not COLA:
|
886 |
+
|
887 |
+
>>> signal.check_COLA(signal.windows.hann(120, sym=True), 120, 60)
|
888 |
+
False
|
889 |
+
|
890 |
+
"Periodic" or "DFT-even" Hann window (for FFT analysis) is COLA for
|
891 |
+
overlap of 1/2, 2/3, 3/4, etc.:
|
892 |
+
|
893 |
+
>>> signal.check_COLA(signal.windows.hann(120, sym=False), 120, 60)
|
894 |
+
True
|
895 |
+
|
896 |
+
>>> signal.check_COLA(signal.windows.hann(120, sym=False), 120, 80)
|
897 |
+
True
|
898 |
+
|
899 |
+
>>> signal.check_COLA(signal.windows.hann(120, sym=False), 120, 90)
|
900 |
+
True
|
901 |
+
|
902 |
+
"""
|
903 |
+
nperseg = int(nperseg)
|
904 |
+
|
905 |
+
if nperseg < 1:
|
906 |
+
raise ValueError('nperseg must be a positive integer')
|
907 |
+
|
908 |
+
if noverlap >= nperseg:
|
909 |
+
raise ValueError('noverlap must be less than nperseg.')
|
910 |
+
noverlap = int(noverlap)
|
911 |
+
|
912 |
+
if isinstance(window, str) or type(window) is tuple:
|
913 |
+
win = get_window(window, nperseg)
|
914 |
+
else:
|
915 |
+
win = np.asarray(window)
|
916 |
+
if len(win.shape) != 1:
|
917 |
+
raise ValueError('window must be 1-D')
|
918 |
+
if win.shape[0] != nperseg:
|
919 |
+
raise ValueError('window must have length of nperseg')
|
920 |
+
|
921 |
+
step = nperseg - noverlap
|
922 |
+
binsums = sum(win[ii*step:(ii+1)*step] for ii in range(nperseg//step))
|
923 |
+
|
924 |
+
if nperseg % step != 0:
|
925 |
+
binsums[:nperseg % step] += win[-(nperseg % step):]
|
926 |
+
|
927 |
+
deviation = binsums - np.median(binsums)
|
928 |
+
return np.max(np.abs(deviation)) < tol
|
929 |
+
|
930 |
+
|
931 |
+
def check_NOLA(window, nperseg, noverlap, tol=1e-10):
|
932 |
+
r"""Check whether the Nonzero Overlap Add (NOLA) constraint is met.
|
933 |
+
|
934 |
+
Parameters
|
935 |
+
----------
|
936 |
+
window : str or tuple or array_like
|
937 |
+
Desired window to use. If `window` is a string or tuple, it is
|
938 |
+
passed to `get_window` to generate the window values, which are
|
939 |
+
DFT-even by default. See `get_window` for a list of windows and
|
940 |
+
required parameters. If `window` is array_like it will be used
|
941 |
+
directly as the window and its length must be nperseg.
|
942 |
+
nperseg : int
|
943 |
+
Length of each segment.
|
944 |
+
noverlap : int
|
945 |
+
Number of points to overlap between segments.
|
946 |
+
tol : float, optional
|
947 |
+
The allowed variance of a bin's weighted sum from the median bin
|
948 |
+
sum.
|
949 |
+
|
950 |
+
Returns
|
951 |
+
-------
|
952 |
+
verdict : bool
|
953 |
+
`True` if chosen combination satisfies the NOLA constraint within
|
954 |
+
`tol`, `False` otherwise
|
955 |
+
|
956 |
+
See Also
|
957 |
+
--------
|
958 |
+
check_COLA: Check whether the Constant OverLap Add (COLA) constraint is met
|
959 |
+
stft: Short Time Fourier Transform
|
960 |
+
istft: Inverse Short Time Fourier Transform
|
961 |
+
|
962 |
+
Notes
|
963 |
+
-----
|
964 |
+
In order to enable inversion of an STFT via the inverse STFT in
|
965 |
+
`istft`, the signal windowing must obey the constraint of "nonzero
|
966 |
+
overlap add" (NOLA):
|
967 |
+
|
968 |
+
.. math:: \sum_{t}w^{2}[n-tH] \ne 0
|
969 |
+
|
970 |
+
for all :math:`n`, where :math:`w` is the window function, :math:`t` is the
|
971 |
+
frame index, and :math:`H` is the hop size (:math:`H` = `nperseg` -
|
972 |
+
`noverlap`).
|
973 |
+
|
974 |
+
This ensures that the normalization factors in the denominator of the
|
975 |
+
overlap-add inversion equation are not zero. Only very pathological windows
|
976 |
+
will fail the NOLA constraint.
|
977 |
+
|
978 |
+
.. versionadded:: 1.2.0
|
979 |
+
|
980 |
+
References
|
981 |
+
----------
|
982 |
+
.. [1] Julius O. Smith III, "Spectral Audio Signal Processing", W3K
|
983 |
+
Publishing, 2011,ISBN 978-0-9745607-3-1.
|
984 |
+
.. [2] G. Heinzel, A. Ruediger and R. Schilling, "Spectrum and
|
985 |
+
spectral density estimation by the Discrete Fourier transform
|
986 |
+
(DFT), including a comprehensive list of window functions and
|
987 |
+
some new at-top windows", 2002,
|
988 |
+
http://hdl.handle.net/11858/00-001M-0000-0013-557A-5
|
989 |
+
|
990 |
+
Examples
|
991 |
+
--------
|
992 |
+
>>> import numpy as np
|
993 |
+
>>> from scipy import signal
|
994 |
+
|
995 |
+
Confirm NOLA condition for rectangular window of 75% (3/4) overlap:
|
996 |
+
|
997 |
+
>>> signal.check_NOLA(signal.windows.boxcar(100), 100, 75)
|
998 |
+
True
|
999 |
+
|
1000 |
+
NOLA is also true for 25% (1/4) overlap:
|
1001 |
+
|
1002 |
+
>>> signal.check_NOLA(signal.windows.boxcar(100), 100, 25)
|
1003 |
+
True
|
1004 |
+
|
1005 |
+
"Symmetrical" Hann window (for filter design) is also NOLA:
|
1006 |
+
|
1007 |
+
>>> signal.check_NOLA(signal.windows.hann(120, sym=True), 120, 60)
|
1008 |
+
True
|
1009 |
+
|
1010 |
+
As long as there is overlap, it takes quite a pathological window to fail
|
1011 |
+
NOLA:
|
1012 |
+
|
1013 |
+
>>> w = np.ones(64, dtype="float")
|
1014 |
+
>>> w[::2] = 0
|
1015 |
+
>>> signal.check_NOLA(w, 64, 32)
|
1016 |
+
False
|
1017 |
+
|
1018 |
+
If there is not enough overlap, a window with zeros at the ends will not
|
1019 |
+
work:
|
1020 |
+
|
1021 |
+
>>> signal.check_NOLA(signal.windows.hann(64), 64, 0)
|
1022 |
+
False
|
1023 |
+
>>> signal.check_NOLA(signal.windows.hann(64), 64, 1)
|
1024 |
+
False
|
1025 |
+
>>> signal.check_NOLA(signal.windows.hann(64), 64, 2)
|
1026 |
+
True
|
1027 |
+
|
1028 |
+
"""
|
1029 |
+
nperseg = int(nperseg)
|
1030 |
+
|
1031 |
+
if nperseg < 1:
|
1032 |
+
raise ValueError('nperseg must be a positive integer')
|
1033 |
+
|
1034 |
+
if noverlap >= nperseg:
|
1035 |
+
raise ValueError('noverlap must be less than nperseg')
|
1036 |
+
if noverlap < 0:
|
1037 |
+
raise ValueError('noverlap must be a nonnegative integer')
|
1038 |
+
noverlap = int(noverlap)
|
1039 |
+
|
1040 |
+
if isinstance(window, str) or type(window) is tuple:
|
1041 |
+
win = get_window(window, nperseg)
|
1042 |
+
else:
|
1043 |
+
win = np.asarray(window)
|
1044 |
+
if len(win.shape) != 1:
|
1045 |
+
raise ValueError('window must be 1-D')
|
1046 |
+
if win.shape[0] != nperseg:
|
1047 |
+
raise ValueError('window must have length of nperseg')
|
1048 |
+
|
1049 |
+
step = nperseg - noverlap
|
1050 |
+
binsums = sum(win[ii*step:(ii+1)*step]**2 for ii in range(nperseg//step))
|
1051 |
+
|
1052 |
+
if nperseg % step != 0:
|
1053 |
+
binsums[:nperseg % step] += win[-(nperseg % step):]**2
|
1054 |
+
|
1055 |
+
return np.min(binsums) > tol
|
1056 |
+
|
1057 |
+
|
1058 |
+
def stft(x, fs=1.0, window='hann', nperseg=256, noverlap=None, nfft=None,
|
1059 |
+
detrend=False, return_onesided=True, boundary='zeros', padded=True,
|
1060 |
+
axis=-1, scaling='spectrum'):
|
1061 |
+
r"""Compute the Short Time Fourier Transform (legacy function).
|
1062 |
+
|
1063 |
+
STFTs can be used as a way of quantifying the change of a
|
1064 |
+
nonstationary signal's frequency and phase content over time.
|
1065 |
+
|
1066 |
+
.. legacy:: function
|
1067 |
+
|
1068 |
+
`ShortTimeFFT` is a newer STFT / ISTFT implementation with more
|
1069 |
+
features. A :ref:`comparison <tutorial_stft_legacy_stft>` between the
|
1070 |
+
implementations can be found in the :ref:`tutorial_stft` section of the
|
1071 |
+
:ref:`user_guide`.
|
1072 |
+
|
1073 |
+
Parameters
|
1074 |
+
----------
|
1075 |
+
x : array_like
|
1076 |
+
Time series of measurement values
|
1077 |
+
fs : float, optional
|
1078 |
+
Sampling frequency of the `x` time series. Defaults to 1.0.
|
1079 |
+
window : str or tuple or array_like, optional
|
1080 |
+
Desired window to use. If `window` is a string or tuple, it is
|
1081 |
+
passed to `get_window` to generate the window values, which are
|
1082 |
+
DFT-even by default. See `get_window` for a list of windows and
|
1083 |
+
required parameters. If `window` is array_like it will be used
|
1084 |
+
directly as the window and its length must be nperseg. Defaults
|
1085 |
+
to a Hann window.
|
1086 |
+
nperseg : int, optional
|
1087 |
+
Length of each segment. Defaults to 256.
|
1088 |
+
noverlap : int, optional
|
1089 |
+
Number of points to overlap between segments. If `None`,
|
1090 |
+
``noverlap = nperseg // 2``. Defaults to `None`. When
|
1091 |
+
specified, the COLA constraint must be met (see Notes below).
|
1092 |
+
nfft : int, optional
|
1093 |
+
Length of the FFT used, if a zero padded FFT is desired. If
|
1094 |
+
`None`, the FFT length is `nperseg`. Defaults to `None`.
|
1095 |
+
detrend : str or function or `False`, optional
|
1096 |
+
Specifies how to detrend each segment. If `detrend` is a
|
1097 |
+
string, it is passed as the `type` argument to the `detrend`
|
1098 |
+
function. If it is a function, it takes a segment and returns a
|
1099 |
+
detrended segment. If `detrend` is `False`, no detrending is
|
1100 |
+
done. Defaults to `False`.
|
1101 |
+
return_onesided : bool, optional
|
1102 |
+
If `True`, return a one-sided spectrum for real data. If
|
1103 |
+
`False` return a two-sided spectrum. Defaults to `True`, but for
|
1104 |
+
complex data, a two-sided spectrum is always returned.
|
1105 |
+
boundary : str or None, optional
|
1106 |
+
Specifies whether the input signal is extended at both ends, and
|
1107 |
+
how to generate the new values, in order to center the first
|
1108 |
+
windowed segment on the first input point. This has the benefit
|
1109 |
+
of enabling reconstruction of the first input point when the
|
1110 |
+
employed window function starts at zero. Valid options are
|
1111 |
+
``['even', 'odd', 'constant', 'zeros', None]``. Defaults to
|
1112 |
+
'zeros', for zero padding extension. I.e. ``[1, 2, 3, 4]`` is
|
1113 |
+
extended to ``[0, 1, 2, 3, 4, 0]`` for ``nperseg=3``.
|
1114 |
+
padded : bool, optional
|
1115 |
+
Specifies whether the input signal is zero-padded at the end to
|
1116 |
+
make the signal fit exactly into an integer number of window
|
1117 |
+
segments, so that all of the signal is included in the output.
|
1118 |
+
Defaults to `True`. Padding occurs after boundary extension, if
|
1119 |
+
`boundary` is not `None`, and `padded` is `True`, as is the
|
1120 |
+
default.
|
1121 |
+
axis : int, optional
|
1122 |
+
Axis along which the STFT is computed; the default is over the
|
1123 |
+
last axis (i.e. ``axis=-1``).
|
1124 |
+
scaling: {'spectrum', 'psd'}
|
1125 |
+
The default 'spectrum' scaling allows each frequency line of `Zxx` to
|
1126 |
+
be interpreted as a magnitude spectrum. The 'psd' option scales each
|
1127 |
+
line to a power spectral density - it allows to calculate the signal's
|
1128 |
+
energy by numerically integrating over ``abs(Zxx)**2``.
|
1129 |
+
|
1130 |
+
.. versionadded:: 1.9.0
|
1131 |
+
|
1132 |
+
Returns
|
1133 |
+
-------
|
1134 |
+
f : ndarray
|
1135 |
+
Array of sample frequencies.
|
1136 |
+
t : ndarray
|
1137 |
+
Array of segment times.
|
1138 |
+
Zxx : ndarray
|
1139 |
+
STFT of `x`. By default, the last axis of `Zxx` corresponds
|
1140 |
+
to the segment times.
|
1141 |
+
|
1142 |
+
See Also
|
1143 |
+
--------
|
1144 |
+
istft: Inverse Short Time Fourier Transform
|
1145 |
+
ShortTimeFFT: Newer STFT/ISTFT implementation providing more features.
|
1146 |
+
check_COLA: Check whether the Constant OverLap Add (COLA) constraint
|
1147 |
+
is met
|
1148 |
+
check_NOLA: Check whether the Nonzero Overlap Add (NOLA) constraint is met
|
1149 |
+
welch: Power spectral density by Welch's method.
|
1150 |
+
spectrogram: Spectrogram by Welch's method.
|
1151 |
+
csd: Cross spectral density by Welch's method.
|
1152 |
+
lombscargle: Lomb-Scargle periodogram for unevenly sampled data
|
1153 |
+
|
1154 |
+
Notes
|
1155 |
+
-----
|
1156 |
+
In order to enable inversion of an STFT via the inverse STFT in
|
1157 |
+
`istft`, the signal windowing must obey the constraint of "Nonzero
|
1158 |
+
OverLap Add" (NOLA), and the input signal must have complete
|
1159 |
+
windowing coverage (i.e. ``(x.shape[axis] - nperseg) %
|
1160 |
+
(nperseg-noverlap) == 0``). The `padded` argument may be used to
|
1161 |
+
accomplish this.
|
1162 |
+
|
1163 |
+
Given a time-domain signal :math:`x[n]`, a window :math:`w[n]`, and a hop
|
1164 |
+
size :math:`H` = `nperseg - noverlap`, the windowed frame at time index
|
1165 |
+
:math:`t` is given by
|
1166 |
+
|
1167 |
+
.. math:: x_{t}[n]=x[n]w[n-tH]
|
1168 |
+
|
1169 |
+
The overlap-add (OLA) reconstruction equation is given by
|
1170 |
+
|
1171 |
+
.. math:: x[n]=\frac{\sum_{t}x_{t}[n]w[n-tH]}{\sum_{t}w^{2}[n-tH]}
|
1172 |
+
|
1173 |
+
The NOLA constraint ensures that every normalization term that appears
|
1174 |
+
in the denomimator of the OLA reconstruction equation is nonzero. Whether a
|
1175 |
+
choice of `window`, `nperseg`, and `noverlap` satisfy this constraint can
|
1176 |
+
be tested with `check_NOLA`.
|
1177 |
+
|
1178 |
+
|
1179 |
+
.. versionadded:: 0.19.0
|
1180 |
+
|
1181 |
+
References
|
1182 |
+
----------
|
1183 |
+
.. [1] Oppenheim, Alan V., Ronald W. Schafer, John R. Buck
|
1184 |
+
"Discrete-Time Signal Processing", Prentice Hall, 1999.
|
1185 |
+
.. [2] Daniel W. Griffin, Jae S. Lim "Signal Estimation from
|
1186 |
+
Modified Short-Time Fourier Transform", IEEE 1984,
|
1187 |
+
10.1109/TASSP.1984.1164317
|
1188 |
+
|
1189 |
+
Examples
|
1190 |
+
--------
|
1191 |
+
>>> import numpy as np
|
1192 |
+
>>> from scipy import signal
|
1193 |
+
>>> import matplotlib.pyplot as plt
|
1194 |
+
>>> rng = np.random.default_rng()
|
1195 |
+
|
1196 |
+
Generate a test signal, a 2 Vrms sine wave whose frequency is slowly
|
1197 |
+
modulated around 3kHz, corrupted by white noise of exponentially
|
1198 |
+
decreasing magnitude sampled at 10 kHz.
|
1199 |
+
|
1200 |
+
>>> fs = 10e3
|
1201 |
+
>>> N = 1e5
|
1202 |
+
>>> amp = 2 * np.sqrt(2)
|
1203 |
+
>>> noise_power = 0.01 * fs / 2
|
1204 |
+
>>> time = np.arange(N) / float(fs)
|
1205 |
+
>>> mod = 500*np.cos(2*np.pi*0.25*time)
|
1206 |
+
>>> carrier = amp * np.sin(2*np.pi*3e3*time + mod)
|
1207 |
+
>>> noise = rng.normal(scale=np.sqrt(noise_power),
|
1208 |
+
... size=time.shape)
|
1209 |
+
>>> noise *= np.exp(-time/5)
|
1210 |
+
>>> x = carrier + noise
|
1211 |
+
|
1212 |
+
Compute and plot the STFT's magnitude.
|
1213 |
+
|
1214 |
+
>>> f, t, Zxx = signal.stft(x, fs, nperseg=1000)
|
1215 |
+
>>> plt.pcolormesh(t, f, np.abs(Zxx), vmin=0, vmax=amp, shading='gouraud')
|
1216 |
+
>>> plt.title('STFT Magnitude')
|
1217 |
+
>>> plt.ylabel('Frequency [Hz]')
|
1218 |
+
>>> plt.xlabel('Time [sec]')
|
1219 |
+
>>> plt.show()
|
1220 |
+
|
1221 |
+
Compare the energy of the signal `x` with the energy of its STFT:
|
1222 |
+
|
1223 |
+
>>> E_x = sum(x**2) / fs # Energy of x
|
1224 |
+
>>> # Calculate a two-sided STFT with PSD scaling:
|
1225 |
+
>>> f, t, Zxx = signal.stft(x, fs, nperseg=1000, return_onesided=False,
|
1226 |
+
... scaling='psd')
|
1227 |
+
>>> # Integrate numerically over abs(Zxx)**2:
|
1228 |
+
>>> df, dt = f[1] - f[0], t[1] - t[0]
|
1229 |
+
>>> E_Zxx = sum(np.sum(Zxx.real**2 + Zxx.imag**2, axis=0) * df) * dt
|
1230 |
+
>>> # The energy is the same, but the numerical errors are quite large:
|
1231 |
+
>>> np.isclose(E_x, E_Zxx, rtol=1e-2)
|
1232 |
+
True
|
1233 |
+
|
1234 |
+
"""
|
1235 |
+
if scaling == 'psd':
|
1236 |
+
scaling = 'density'
|
1237 |
+
elif scaling != 'spectrum':
|
1238 |
+
raise ValueError(f"Parameter {scaling=} not in ['spectrum', 'psd']!")
|
1239 |
+
|
1240 |
+
freqs, time, Zxx = _spectral_helper(x, x, fs, window, nperseg, noverlap,
|
1241 |
+
nfft, detrend, return_onesided,
|
1242 |
+
scaling=scaling, axis=axis,
|
1243 |
+
mode='stft', boundary=boundary,
|
1244 |
+
padded=padded)
|
1245 |
+
|
1246 |
+
return freqs, time, Zxx
|
1247 |
+
|
1248 |
+
|
1249 |
+
def istft(Zxx, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None,
|
1250 |
+
input_onesided=True, boundary=True, time_axis=-1, freq_axis=-2,
|
1251 |
+
scaling='spectrum'):
|
1252 |
+
r"""Perform the inverse Short Time Fourier transform (legacy function).
|
1253 |
+
|
1254 |
+
.. legacy:: function
|
1255 |
+
|
1256 |
+
`ShortTimeFFT` is a newer STFT / ISTFT implementation with more
|
1257 |
+
features. A :ref:`comparison <tutorial_stft_legacy_stft>` between the
|
1258 |
+
implementations can be found in the :ref:`tutorial_stft` section of the
|
1259 |
+
:ref:`user_guide`.
|
1260 |
+
|
1261 |
+
Parameters
|
1262 |
+
----------
|
1263 |
+
Zxx : array_like
|
1264 |
+
STFT of the signal to be reconstructed. If a purely real array
|
1265 |
+
is passed, it will be cast to a complex data type.
|
1266 |
+
fs : float, optional
|
1267 |
+
Sampling frequency of the time series. Defaults to 1.0.
|
1268 |
+
window : str or tuple or array_like, optional
|
1269 |
+
Desired window to use. If `window` is a string or tuple, it is
|
1270 |
+
passed to `get_window` to generate the window values, which are
|
1271 |
+
DFT-even by default. See `get_window` for a list of windows and
|
1272 |
+
required parameters. If `window` is array_like it will be used
|
1273 |
+
directly as the window and its length must be nperseg. Defaults
|
1274 |
+
to a Hann window. Must match the window used to generate the
|
1275 |
+
STFT for faithful inversion.
|
1276 |
+
nperseg : int, optional
|
1277 |
+
Number of data points corresponding to each STFT segment. This
|
1278 |
+
parameter must be specified if the number of data points per
|
1279 |
+
segment is odd, or if the STFT was padded via ``nfft >
|
1280 |
+
nperseg``. If `None`, the value depends on the shape of
|
1281 |
+
`Zxx` and `input_onesided`. If `input_onesided` is `True`,
|
1282 |
+
``nperseg=2*(Zxx.shape[freq_axis] - 1)``. Otherwise,
|
1283 |
+
``nperseg=Zxx.shape[freq_axis]``. Defaults to `None`.
|
1284 |
+
noverlap : int, optional
|
1285 |
+
Number of points to overlap between segments. If `None`, half
|
1286 |
+
of the segment length. Defaults to `None`. When specified, the
|
1287 |
+
COLA constraint must be met (see Notes below), and should match
|
1288 |
+
the parameter used to generate the STFT. Defaults to `None`.
|
1289 |
+
nfft : int, optional
|
1290 |
+
Number of FFT points corresponding to each STFT segment. This
|
1291 |
+
parameter must be specified if the STFT was padded via ``nfft >
|
1292 |
+
nperseg``. If `None`, the default values are the same as for
|
1293 |
+
`nperseg`, detailed above, with one exception: if
|
1294 |
+
`input_onesided` is True and
|
1295 |
+
``nperseg==2*Zxx.shape[freq_axis] - 1``, `nfft` also takes on
|
1296 |
+
that value. This case allows the proper inversion of an
|
1297 |
+
odd-length unpadded STFT using ``nfft=None``. Defaults to
|
1298 |
+
`None`.
|
1299 |
+
input_onesided : bool, optional
|
1300 |
+
If `True`, interpret the input array as one-sided FFTs, such
|
1301 |
+
as is returned by `stft` with ``return_onesided=True`` and
|
1302 |
+
`numpy.fft.rfft`. If `False`, interpret the input as a a
|
1303 |
+
two-sided FFT. Defaults to `True`.
|
1304 |
+
boundary : bool, optional
|
1305 |
+
Specifies whether the input signal was extended at its
|
1306 |
+
boundaries by supplying a non-`None` ``boundary`` argument to
|
1307 |
+
`stft`. Defaults to `True`.
|
1308 |
+
time_axis : int, optional
|
1309 |
+
Where the time segments of the STFT is located; the default is
|
1310 |
+
the last axis (i.e. ``axis=-1``).
|
1311 |
+
freq_axis : int, optional
|
1312 |
+
Where the frequency axis of the STFT is located; the default is
|
1313 |
+
the penultimate axis (i.e. ``axis=-2``).
|
1314 |
+
scaling: {'spectrum', 'psd'}
|
1315 |
+
The default 'spectrum' scaling allows each frequency line of `Zxx` to
|
1316 |
+
be interpreted as a magnitude spectrum. The 'psd' option scales each
|
1317 |
+
line to a power spectral density - it allows to calculate the signal's
|
1318 |
+
energy by numerically integrating over ``abs(Zxx)**2``.
|
1319 |
+
|
1320 |
+
Returns
|
1321 |
+
-------
|
1322 |
+
t : ndarray
|
1323 |
+
Array of output data times.
|
1324 |
+
x : ndarray
|
1325 |
+
iSTFT of `Zxx`.
|
1326 |
+
|
1327 |
+
See Also
|
1328 |
+
--------
|
1329 |
+
stft: Short Time Fourier Transform
|
1330 |
+
ShortTimeFFT: Newer STFT/ISTFT implementation providing more features.
|
1331 |
+
check_COLA: Check whether the Constant OverLap Add (COLA) constraint
|
1332 |
+
is met
|
1333 |
+
check_NOLA: Check whether the Nonzero Overlap Add (NOLA) constraint is met
|
1334 |
+
|
1335 |
+
Notes
|
1336 |
+
-----
|
1337 |
+
In order to enable inversion of an STFT via the inverse STFT with
|
1338 |
+
`istft`, the signal windowing must obey the constraint of "nonzero
|
1339 |
+
overlap add" (NOLA):
|
1340 |
+
|
1341 |
+
.. math:: \sum_{t}w^{2}[n-tH] \ne 0
|
1342 |
+
|
1343 |
+
This ensures that the normalization factors that appear in the denominator
|
1344 |
+
of the overlap-add reconstruction equation
|
1345 |
+
|
1346 |
+
.. math:: x[n]=\frac{\sum_{t}x_{t}[n]w[n-tH]}{\sum_{t}w^{2}[n-tH]}
|
1347 |
+
|
1348 |
+
are not zero. The NOLA constraint can be checked with the `check_NOLA`
|
1349 |
+
function.
|
1350 |
+
|
1351 |
+
An STFT which has been modified (via masking or otherwise) is not
|
1352 |
+
guaranteed to correspond to a exactly realizible signal. This
|
1353 |
+
function implements the iSTFT via the least-squares estimation
|
1354 |
+
algorithm detailed in [2]_, which produces a signal that minimizes
|
1355 |
+
the mean squared error between the STFT of the returned signal and
|
1356 |
+
the modified STFT.
|
1357 |
+
|
1358 |
+
|
1359 |
+
.. versionadded:: 0.19.0
|
1360 |
+
|
1361 |
+
References
|
1362 |
+
----------
|
1363 |
+
.. [1] Oppenheim, Alan V., Ronald W. Schafer, John R. Buck
|
1364 |
+
"Discrete-Time Signal Processing", Prentice Hall, 1999.
|
1365 |
+
.. [2] Daniel W. Griffin, Jae S. Lim "Signal Estimation from
|
1366 |
+
Modified Short-Time Fourier Transform", IEEE 1984,
|
1367 |
+
10.1109/TASSP.1984.1164317
|
1368 |
+
|
1369 |
+
Examples
|
1370 |
+
--------
|
1371 |
+
>>> import numpy as np
|
1372 |
+
>>> from scipy import signal
|
1373 |
+
>>> import matplotlib.pyplot as plt
|
1374 |
+
>>> rng = np.random.default_rng()
|
1375 |
+
|
1376 |
+
Generate a test signal, a 2 Vrms sine wave at 50Hz corrupted by
|
1377 |
+
0.001 V**2/Hz of white noise sampled at 1024 Hz.
|
1378 |
+
|
1379 |
+
>>> fs = 1024
|
1380 |
+
>>> N = 10*fs
|
1381 |
+
>>> nperseg = 512
|
1382 |
+
>>> amp = 2 * np.sqrt(2)
|
1383 |
+
>>> noise_power = 0.001 * fs / 2
|
1384 |
+
>>> time = np.arange(N) / float(fs)
|
1385 |
+
>>> carrier = amp * np.sin(2*np.pi*50*time)
|
1386 |
+
>>> noise = rng.normal(scale=np.sqrt(noise_power),
|
1387 |
+
... size=time.shape)
|
1388 |
+
>>> x = carrier + noise
|
1389 |
+
|
1390 |
+
Compute the STFT, and plot its magnitude
|
1391 |
+
|
1392 |
+
>>> f, t, Zxx = signal.stft(x, fs=fs, nperseg=nperseg)
|
1393 |
+
>>> plt.figure()
|
1394 |
+
>>> plt.pcolormesh(t, f, np.abs(Zxx), vmin=0, vmax=amp, shading='gouraud')
|
1395 |
+
>>> plt.ylim([f[1], f[-1]])
|
1396 |
+
>>> plt.title('STFT Magnitude')
|
1397 |
+
>>> plt.ylabel('Frequency [Hz]')
|
1398 |
+
>>> plt.xlabel('Time [sec]')
|
1399 |
+
>>> plt.yscale('log')
|
1400 |
+
>>> plt.show()
|
1401 |
+
|
1402 |
+
Zero the components that are 10% or less of the carrier magnitude,
|
1403 |
+
then convert back to a time series via inverse STFT
|
1404 |
+
|
1405 |
+
>>> Zxx = np.where(np.abs(Zxx) >= amp/10, Zxx, 0)
|
1406 |
+
>>> _, xrec = signal.istft(Zxx, fs)
|
1407 |
+
|
1408 |
+
Compare the cleaned signal with the original and true carrier signals.
|
1409 |
+
|
1410 |
+
>>> plt.figure()
|
1411 |
+
>>> plt.plot(time, x, time, xrec, time, carrier)
|
1412 |
+
>>> plt.xlim([2, 2.1])
|
1413 |
+
>>> plt.xlabel('Time [sec]')
|
1414 |
+
>>> plt.ylabel('Signal')
|
1415 |
+
>>> plt.legend(['Carrier + Noise', 'Filtered via STFT', 'True Carrier'])
|
1416 |
+
>>> plt.show()
|
1417 |
+
|
1418 |
+
Note that the cleaned signal does not start as abruptly as the original,
|
1419 |
+
since some of the coefficients of the transient were also removed:
|
1420 |
+
|
1421 |
+
>>> plt.figure()
|
1422 |
+
>>> plt.plot(time, x, time, xrec, time, carrier)
|
1423 |
+
>>> plt.xlim([0, 0.1])
|
1424 |
+
>>> plt.xlabel('Time [sec]')
|
1425 |
+
>>> plt.ylabel('Signal')
|
1426 |
+
>>> plt.legend(['Carrier + Noise', 'Filtered via STFT', 'True Carrier'])
|
1427 |
+
>>> plt.show()
|
1428 |
+
|
1429 |
+
"""
|
1430 |
+
# Make sure input is an ndarray of appropriate complex dtype
|
1431 |
+
Zxx = np.asarray(Zxx) + 0j
|
1432 |
+
freq_axis = int(freq_axis)
|
1433 |
+
time_axis = int(time_axis)
|
1434 |
+
|
1435 |
+
if Zxx.ndim < 2:
|
1436 |
+
raise ValueError('Input stft must be at least 2d!')
|
1437 |
+
|
1438 |
+
if freq_axis == time_axis:
|
1439 |
+
raise ValueError('Must specify differing time and frequency axes!')
|
1440 |
+
|
1441 |
+
nseg = Zxx.shape[time_axis]
|
1442 |
+
|
1443 |
+
if input_onesided:
|
1444 |
+
# Assume even segment length
|
1445 |
+
n_default = 2*(Zxx.shape[freq_axis] - 1)
|
1446 |
+
else:
|
1447 |
+
n_default = Zxx.shape[freq_axis]
|
1448 |
+
|
1449 |
+
# Check windowing parameters
|
1450 |
+
if nperseg is None:
|
1451 |
+
nperseg = n_default
|
1452 |
+
else:
|
1453 |
+
nperseg = int(nperseg)
|
1454 |
+
if nperseg < 1:
|
1455 |
+
raise ValueError('nperseg must be a positive integer')
|
1456 |
+
|
1457 |
+
if nfft is None:
|
1458 |
+
if (input_onesided) and (nperseg == n_default + 1):
|
1459 |
+
# Odd nperseg, no FFT padding
|
1460 |
+
nfft = nperseg
|
1461 |
+
else:
|
1462 |
+
nfft = n_default
|
1463 |
+
elif nfft < nperseg:
|
1464 |
+
raise ValueError('nfft must be greater than or equal to nperseg.')
|
1465 |
+
else:
|
1466 |
+
nfft = int(nfft)
|
1467 |
+
|
1468 |
+
if noverlap is None:
|
1469 |
+
noverlap = nperseg//2
|
1470 |
+
else:
|
1471 |
+
noverlap = int(noverlap)
|
1472 |
+
if noverlap >= nperseg:
|
1473 |
+
raise ValueError('noverlap must be less than nperseg.')
|
1474 |
+
nstep = nperseg - noverlap
|
1475 |
+
|
1476 |
+
# Rearrange axes if necessary
|
1477 |
+
if time_axis != Zxx.ndim-1 or freq_axis != Zxx.ndim-2:
|
1478 |
+
# Turn negative indices to positive for the call to transpose
|
1479 |
+
if freq_axis < 0:
|
1480 |
+
freq_axis = Zxx.ndim + freq_axis
|
1481 |
+
if time_axis < 0:
|
1482 |
+
time_axis = Zxx.ndim + time_axis
|
1483 |
+
zouter = list(range(Zxx.ndim))
|
1484 |
+
for ax in sorted([time_axis, freq_axis], reverse=True):
|
1485 |
+
zouter.pop(ax)
|
1486 |
+
Zxx = np.transpose(Zxx, zouter+[freq_axis, time_axis])
|
1487 |
+
|
1488 |
+
# Get window as array
|
1489 |
+
if isinstance(window, str) or type(window) is tuple:
|
1490 |
+
win = get_window(window, nperseg)
|
1491 |
+
else:
|
1492 |
+
win = np.asarray(window)
|
1493 |
+
if len(win.shape) != 1:
|
1494 |
+
raise ValueError('window must be 1-D')
|
1495 |
+
if win.shape[0] != nperseg:
|
1496 |
+
raise ValueError(f'window must have length of {nperseg}')
|
1497 |
+
|
1498 |
+
ifunc = sp_fft.irfft if input_onesided else sp_fft.ifft
|
1499 |
+
xsubs = ifunc(Zxx, axis=-2, n=nfft)[..., :nperseg, :]
|
1500 |
+
|
1501 |
+
# Initialize output and normalization arrays
|
1502 |
+
outputlength = nperseg + (nseg-1)*nstep
|
1503 |
+
x = np.zeros(list(Zxx.shape[:-2])+[outputlength], dtype=xsubs.dtype)
|
1504 |
+
norm = np.zeros(outputlength, dtype=xsubs.dtype)
|
1505 |
+
|
1506 |
+
if np.result_type(win, xsubs) != xsubs.dtype:
|
1507 |
+
win = win.astype(xsubs.dtype)
|
1508 |
+
|
1509 |
+
if scaling == 'spectrum':
|
1510 |
+
xsubs *= win.sum()
|
1511 |
+
elif scaling == 'psd':
|
1512 |
+
xsubs *= np.sqrt(fs * sum(win**2))
|
1513 |
+
else:
|
1514 |
+
raise ValueError(f"Parameter {scaling=} not in ['spectrum', 'psd']!")
|
1515 |
+
|
1516 |
+
# Construct the output from the ifft segments
|
1517 |
+
# This loop could perhaps be vectorized/strided somehow...
|
1518 |
+
for ii in range(nseg):
|
1519 |
+
# Window the ifft
|
1520 |
+
x[..., ii*nstep:ii*nstep+nperseg] += xsubs[..., ii] * win
|
1521 |
+
norm[..., ii*nstep:ii*nstep+nperseg] += win**2
|
1522 |
+
|
1523 |
+
# Remove extension points
|
1524 |
+
if boundary:
|
1525 |
+
x = x[..., nperseg//2:-(nperseg//2)]
|
1526 |
+
norm = norm[..., nperseg//2:-(nperseg//2)]
|
1527 |
+
|
1528 |
+
# Divide out normalization where non-tiny
|
1529 |
+
if np.sum(norm > 1e-10) != len(norm):
|
1530 |
+
warnings.warn(
|
1531 |
+
"NOLA condition failed, STFT may not be invertible."
|
1532 |
+
+ (" Possibly due to missing boundary" if not boundary else ""),
|
1533 |
+
stacklevel=2
|
1534 |
+
)
|
1535 |
+
x /= np.where(norm > 1e-10, norm, 1.0)
|
1536 |
+
|
1537 |
+
if input_onesided:
|
1538 |
+
x = x.real
|
1539 |
+
|
1540 |
+
# Put axes back
|
1541 |
+
if x.ndim > 1:
|
1542 |
+
if time_axis != Zxx.ndim-1:
|
1543 |
+
if freq_axis < time_axis:
|
1544 |
+
time_axis -= 1
|
1545 |
+
x = np.moveaxis(x, -1, time_axis)
|
1546 |
+
|
1547 |
+
time = np.arange(x.shape[0])/float(fs)
|
1548 |
+
return time, x
|
1549 |
+
|
1550 |
+
|
1551 |
+
def coherence(x, y, fs=1.0, window='hann', nperseg=None, noverlap=None,
|
1552 |
+
nfft=None, detrend='constant', axis=-1):
|
1553 |
+
r"""
|
1554 |
+
Estimate the magnitude squared coherence estimate, Cxy, of
|
1555 |
+
discrete-time signals X and Y using Welch's method.
|
1556 |
+
|
1557 |
+
``Cxy = abs(Pxy)**2/(Pxx*Pyy)``, where `Pxx` and `Pyy` are power
|
1558 |
+
spectral density estimates of X and Y, and `Pxy` is the cross
|
1559 |
+
spectral density estimate of X and Y.
|
1560 |
+
|
1561 |
+
Parameters
|
1562 |
+
----------
|
1563 |
+
x : array_like
|
1564 |
+
Time series of measurement values
|
1565 |
+
y : array_like
|
1566 |
+
Time series of measurement values
|
1567 |
+
fs : float, optional
|
1568 |
+
Sampling frequency of the `x` and `y` time series. Defaults
|
1569 |
+
to 1.0.
|
1570 |
+
window : str or tuple or array_like, optional
|
1571 |
+
Desired window to use. If `window` is a string or tuple, it is
|
1572 |
+
passed to `get_window` to generate the window values, which are
|
1573 |
+
DFT-even by default. See `get_window` for a list of windows and
|
1574 |
+
required parameters. If `window` is array_like it will be used
|
1575 |
+
directly as the window and its length must be nperseg. Defaults
|
1576 |
+
to a Hann window.
|
1577 |
+
nperseg : int, optional
|
1578 |
+
Length of each segment. Defaults to None, but if window is str or
|
1579 |
+
tuple, is set to 256, and if window is array_like, is set to the
|
1580 |
+
length of the window.
|
1581 |
+
noverlap: int, optional
|
1582 |
+
Number of points to overlap between segments. If `None`,
|
1583 |
+
``noverlap = nperseg // 2``. Defaults to `None`.
|
1584 |
+
nfft : int, optional
|
1585 |
+
Length of the FFT used, if a zero padded FFT is desired. If
|
1586 |
+
`None`, the FFT length is `nperseg`. Defaults to `None`.
|
1587 |
+
detrend : str or function or `False`, optional
|
1588 |
+
Specifies how to detrend each segment. If `detrend` is a
|
1589 |
+
string, it is passed as the `type` argument to the `detrend`
|
1590 |
+
function. If it is a function, it takes a segment and returns a
|
1591 |
+
detrended segment. If `detrend` is `False`, no detrending is
|
1592 |
+
done. Defaults to 'constant'.
|
1593 |
+
axis : int, optional
|
1594 |
+
Axis along which the coherence is computed for both inputs; the
|
1595 |
+
default is over the last axis (i.e. ``axis=-1``).
|
1596 |
+
|
1597 |
+
Returns
|
1598 |
+
-------
|
1599 |
+
f : ndarray
|
1600 |
+
Array of sample frequencies.
|
1601 |
+
Cxy : ndarray
|
1602 |
+
Magnitude squared coherence of x and y.
|
1603 |
+
|
1604 |
+
See Also
|
1605 |
+
--------
|
1606 |
+
periodogram: Simple, optionally modified periodogram
|
1607 |
+
lombscargle: Lomb-Scargle periodogram for unevenly sampled data
|
1608 |
+
welch: Power spectral density by Welch's method.
|
1609 |
+
csd: Cross spectral density by Welch's method.
|
1610 |
+
|
1611 |
+
Notes
|
1612 |
+
-----
|
1613 |
+
An appropriate amount of overlap will depend on the choice of window
|
1614 |
+
and on your requirements. For the default Hann window an overlap of
|
1615 |
+
50% is a reasonable trade off between accurately estimating the
|
1616 |
+
signal power, while not over counting any of the data. Narrower
|
1617 |
+
windows may require a larger overlap.
|
1618 |
+
|
1619 |
+
.. versionadded:: 0.16.0
|
1620 |
+
|
1621 |
+
References
|
1622 |
+
----------
|
1623 |
+
.. [1] P. Welch, "The use of the fast Fourier transform for the
|
1624 |
+
estimation of power spectra: A method based on time averaging
|
1625 |
+
over short, modified periodograms", IEEE Trans. Audio
|
1626 |
+
Electroacoust. vol. 15, pp. 70-73, 1967.
|
1627 |
+
.. [2] Stoica, Petre, and Randolph Moses, "Spectral Analysis of
|
1628 |
+
Signals" Prentice Hall, 2005
|
1629 |
+
|
1630 |
+
Examples
|
1631 |
+
--------
|
1632 |
+
>>> import numpy as np
|
1633 |
+
>>> from scipy import signal
|
1634 |
+
>>> import matplotlib.pyplot as plt
|
1635 |
+
>>> rng = np.random.default_rng()
|
1636 |
+
|
1637 |
+
Generate two test signals with some common features.
|
1638 |
+
|
1639 |
+
>>> fs = 10e3
|
1640 |
+
>>> N = 1e5
|
1641 |
+
>>> amp = 20
|
1642 |
+
>>> freq = 1234.0
|
1643 |
+
>>> noise_power = 0.001 * fs / 2
|
1644 |
+
>>> time = np.arange(N) / fs
|
1645 |
+
>>> b, a = signal.butter(2, 0.25, 'low')
|
1646 |
+
>>> x = rng.normal(scale=np.sqrt(noise_power), size=time.shape)
|
1647 |
+
>>> y = signal.lfilter(b, a, x)
|
1648 |
+
>>> x += amp*np.sin(2*np.pi*freq*time)
|
1649 |
+
>>> y += rng.normal(scale=0.1*np.sqrt(noise_power), size=time.shape)
|
1650 |
+
|
1651 |
+
Compute and plot the coherence.
|
1652 |
+
|
1653 |
+
>>> f, Cxy = signal.coherence(x, y, fs, nperseg=1024)
|
1654 |
+
>>> plt.semilogy(f, Cxy)
|
1655 |
+
>>> plt.xlabel('frequency [Hz]')
|
1656 |
+
>>> plt.ylabel('Coherence')
|
1657 |
+
>>> plt.show()
|
1658 |
+
|
1659 |
+
"""
|
1660 |
+
freqs, Pxx = welch(x, fs=fs, window=window, nperseg=nperseg,
|
1661 |
+
noverlap=noverlap, nfft=nfft, detrend=detrend,
|
1662 |
+
axis=axis)
|
1663 |
+
_, Pyy = welch(y, fs=fs, window=window, nperseg=nperseg, noverlap=noverlap,
|
1664 |
+
nfft=nfft, detrend=detrend, axis=axis)
|
1665 |
+
_, Pxy = csd(x, y, fs=fs, window=window, nperseg=nperseg,
|
1666 |
+
noverlap=noverlap, nfft=nfft, detrend=detrend, axis=axis)
|
1667 |
+
|
1668 |
+
Cxy = np.abs(Pxy)**2 / Pxx / Pyy
|
1669 |
+
|
1670 |
+
return freqs, Cxy
|
1671 |
+
|
1672 |
+
|
1673 |
+
def _spectral_helper(x, y, fs=1.0, window='hann', nperseg=None, noverlap=None,
|
1674 |
+
nfft=None, detrend='constant', return_onesided=True,
|
1675 |
+
scaling='density', axis=-1, mode='psd', boundary=None,
|
1676 |
+
padded=False):
|
1677 |
+
"""Calculate various forms of windowed FFTs for PSD, CSD, etc.
|
1678 |
+
|
1679 |
+
This is a helper function that implements the commonality between
|
1680 |
+
the stft, psd, csd, and spectrogram functions. It is not designed to
|
1681 |
+
be called externally. The windows are not averaged over; the result
|
1682 |
+
from each window is returned.
|
1683 |
+
|
1684 |
+
Parameters
|
1685 |
+
----------
|
1686 |
+
x : array_like
|
1687 |
+
Array or sequence containing the data to be analyzed.
|
1688 |
+
y : array_like
|
1689 |
+
Array or sequence containing the data to be analyzed. If this is
|
1690 |
+
the same object in memory as `x` (i.e. ``_spectral_helper(x,
|
1691 |
+
x, ...)``), the extra computations are spared.
|
1692 |
+
fs : float, optional
|
1693 |
+
Sampling frequency of the time series. Defaults to 1.0.
|
1694 |
+
window : str or tuple or array_like, optional
|
1695 |
+
Desired window to use. If `window` is a string or tuple, it is
|
1696 |
+
passed to `get_window` to generate the window values, which are
|
1697 |
+
DFT-even by default. See `get_window` for a list of windows and
|
1698 |
+
required parameters. If `window` is array_like it will be used
|
1699 |
+
directly as the window and its length must be nperseg. Defaults
|
1700 |
+
to a Hann window.
|
1701 |
+
nperseg : int, optional
|
1702 |
+
Length of each segment. Defaults to None, but if window is str or
|
1703 |
+
tuple, is set to 256, and if window is array_like, is set to the
|
1704 |
+
length of the window.
|
1705 |
+
noverlap : int, optional
|
1706 |
+
Number of points to overlap between segments. If `None`,
|
1707 |
+
``noverlap = nperseg // 2``. Defaults to `None`.
|
1708 |
+
nfft : int, optional
|
1709 |
+
Length of the FFT used, if a zero padded FFT is desired. If
|
1710 |
+
`None`, the FFT length is `nperseg`. Defaults to `None`.
|
1711 |
+
detrend : str or function or `False`, optional
|
1712 |
+
Specifies how to detrend each segment. If `detrend` is a
|
1713 |
+
string, it is passed as the `type` argument to the `detrend`
|
1714 |
+
function. If it is a function, it takes a segment and returns a
|
1715 |
+
detrended segment. If `detrend` is `False`, no detrending is
|
1716 |
+
done. Defaults to 'constant'.
|
1717 |
+
return_onesided : bool, optional
|
1718 |
+
If `True`, return a one-sided spectrum for real data. If
|
1719 |
+
`False` return a two-sided spectrum. Defaults to `True`, but for
|
1720 |
+
complex data, a two-sided spectrum is always returned.
|
1721 |
+
scaling : { 'density', 'spectrum' }, optional
|
1722 |
+
Selects between computing the cross spectral density ('density')
|
1723 |
+
where `Pxy` has units of V**2/Hz and computing the cross
|
1724 |
+
spectrum ('spectrum') where `Pxy` has units of V**2, if `x`
|
1725 |
+
and `y` are measured in V and `fs` is measured in Hz.
|
1726 |
+
Defaults to 'density'
|
1727 |
+
axis : int, optional
|
1728 |
+
Axis along which the FFTs are computed; the default is over the
|
1729 |
+
last axis (i.e. ``axis=-1``).
|
1730 |
+
mode: str {'psd', 'stft'}, optional
|
1731 |
+
Defines what kind of return values are expected. Defaults to
|
1732 |
+
'psd'.
|
1733 |
+
boundary : str or None, optional
|
1734 |
+
Specifies whether the input signal is extended at both ends, and
|
1735 |
+
how to generate the new values, in order to center the first
|
1736 |
+
windowed segment on the first input point. This has the benefit
|
1737 |
+
of enabling reconstruction of the first input point when the
|
1738 |
+
employed window function starts at zero. Valid options are
|
1739 |
+
``['even', 'odd', 'constant', 'zeros', None]``. Defaults to
|
1740 |
+
`None`.
|
1741 |
+
padded : bool, optional
|
1742 |
+
Specifies whether the input signal is zero-padded at the end to
|
1743 |
+
make the signal fit exactly into an integer number of window
|
1744 |
+
segments, so that all of the signal is included in the output.
|
1745 |
+
Defaults to `False`. Padding occurs after boundary extension, if
|
1746 |
+
`boundary` is not `None`, and `padded` is `True`.
|
1747 |
+
|
1748 |
+
Returns
|
1749 |
+
-------
|
1750 |
+
freqs : ndarray
|
1751 |
+
Array of sample frequencies.
|
1752 |
+
t : ndarray
|
1753 |
+
Array of times corresponding to each data segment
|
1754 |
+
result : ndarray
|
1755 |
+
Array of output data, contents dependent on *mode* kwarg.
|
1756 |
+
|
1757 |
+
Notes
|
1758 |
+
-----
|
1759 |
+
Adapted from matplotlib.mlab
|
1760 |
+
|
1761 |
+
.. versionadded:: 0.16.0
|
1762 |
+
"""
|
1763 |
+
if mode not in ['psd', 'stft']:
|
1764 |
+
raise ValueError("Unknown value for mode %s, must be one of: "
|
1765 |
+
"{'psd', 'stft'}" % mode)
|
1766 |
+
|
1767 |
+
boundary_funcs = {'even': even_ext,
|
1768 |
+
'odd': odd_ext,
|
1769 |
+
'constant': const_ext,
|
1770 |
+
'zeros': zero_ext,
|
1771 |
+
None: None}
|
1772 |
+
|
1773 |
+
if boundary not in boundary_funcs:
|
1774 |
+
raise ValueError("Unknown boundary option '{}', must be one of: {}"
|
1775 |
+
.format(boundary, list(boundary_funcs.keys())))
|
1776 |
+
|
1777 |
+
# If x and y are the same object we can save ourselves some computation.
|
1778 |
+
same_data = y is x
|
1779 |
+
|
1780 |
+
if not same_data and mode != 'psd':
|
1781 |
+
raise ValueError("x and y must be equal if mode is 'stft'")
|
1782 |
+
|
1783 |
+
axis = int(axis)
|
1784 |
+
|
1785 |
+
# Ensure we have np.arrays, get outdtype
|
1786 |
+
x = np.asarray(x)
|
1787 |
+
if not same_data:
|
1788 |
+
y = np.asarray(y)
|
1789 |
+
outdtype = np.result_type(x, y, np.complex64)
|
1790 |
+
else:
|
1791 |
+
outdtype = np.result_type(x, np.complex64)
|
1792 |
+
|
1793 |
+
if not same_data:
|
1794 |
+
# Check if we can broadcast the outer axes together
|
1795 |
+
xouter = list(x.shape)
|
1796 |
+
youter = list(y.shape)
|
1797 |
+
xouter.pop(axis)
|
1798 |
+
youter.pop(axis)
|
1799 |
+
try:
|
1800 |
+
outershape = np.broadcast(np.empty(xouter), np.empty(youter)).shape
|
1801 |
+
except ValueError as e:
|
1802 |
+
raise ValueError('x and y cannot be broadcast together.') from e
|
1803 |
+
|
1804 |
+
if same_data:
|
1805 |
+
if x.size == 0:
|
1806 |
+
return np.empty(x.shape), np.empty(x.shape), np.empty(x.shape)
|
1807 |
+
else:
|
1808 |
+
if x.size == 0 or y.size == 0:
|
1809 |
+
outshape = outershape + (min([x.shape[axis], y.shape[axis]]),)
|
1810 |
+
emptyout = np.moveaxis(np.empty(outshape), -1, axis)
|
1811 |
+
return emptyout, emptyout, emptyout
|
1812 |
+
|
1813 |
+
if x.ndim > 1:
|
1814 |
+
if axis != -1:
|
1815 |
+
x = np.moveaxis(x, axis, -1)
|
1816 |
+
if not same_data and y.ndim > 1:
|
1817 |
+
y = np.moveaxis(y, axis, -1)
|
1818 |
+
|
1819 |
+
# Check if x and y are the same length, zero-pad if necessary
|
1820 |
+
if not same_data:
|
1821 |
+
if x.shape[-1] != y.shape[-1]:
|
1822 |
+
if x.shape[-1] < y.shape[-1]:
|
1823 |
+
pad_shape = list(x.shape)
|
1824 |
+
pad_shape[-1] = y.shape[-1] - x.shape[-1]
|
1825 |
+
x = np.concatenate((x, np.zeros(pad_shape)), -1)
|
1826 |
+
else:
|
1827 |
+
pad_shape = list(y.shape)
|
1828 |
+
pad_shape[-1] = x.shape[-1] - y.shape[-1]
|
1829 |
+
y = np.concatenate((y, np.zeros(pad_shape)), -1)
|
1830 |
+
|
1831 |
+
if nperseg is not None: # if specified by user
|
1832 |
+
nperseg = int(nperseg)
|
1833 |
+
if nperseg < 1:
|
1834 |
+
raise ValueError('nperseg must be a positive integer')
|
1835 |
+
|
1836 |
+
# parse window; if array like, then set nperseg = win.shape
|
1837 |
+
win, nperseg = _triage_segments(window, nperseg, input_length=x.shape[-1])
|
1838 |
+
|
1839 |
+
if nfft is None:
|
1840 |
+
nfft = nperseg
|
1841 |
+
elif nfft < nperseg:
|
1842 |
+
raise ValueError('nfft must be greater than or equal to nperseg.')
|
1843 |
+
else:
|
1844 |
+
nfft = int(nfft)
|
1845 |
+
|
1846 |
+
if noverlap is None:
|
1847 |
+
noverlap = nperseg//2
|
1848 |
+
else:
|
1849 |
+
noverlap = int(noverlap)
|
1850 |
+
if noverlap >= nperseg:
|
1851 |
+
raise ValueError('noverlap must be less than nperseg.')
|
1852 |
+
nstep = nperseg - noverlap
|
1853 |
+
|
1854 |
+
# Padding occurs after boundary extension, so that the extended signal ends
|
1855 |
+
# in zeros, instead of introducing an impulse at the end.
|
1856 |
+
# I.e. if x = [..., 3, 2]
|
1857 |
+
# extend then pad -> [..., 3, 2, 2, 3, 0, 0, 0]
|
1858 |
+
# pad then extend -> [..., 3, 2, 0, 0, 0, 2, 3]
|
1859 |
+
|
1860 |
+
if boundary is not None:
|
1861 |
+
ext_func = boundary_funcs[boundary]
|
1862 |
+
x = ext_func(x, nperseg//2, axis=-1)
|
1863 |
+
if not same_data:
|
1864 |
+
y = ext_func(y, nperseg//2, axis=-1)
|
1865 |
+
|
1866 |
+
if padded:
|
1867 |
+
# Pad to integer number of windowed segments
|
1868 |
+
# I.e make x.shape[-1] = nperseg + (nseg-1)*nstep, with integer nseg
|
1869 |
+
nadd = (-(x.shape[-1]-nperseg) % nstep) % nperseg
|
1870 |
+
zeros_shape = list(x.shape[:-1]) + [nadd]
|
1871 |
+
x = np.concatenate((x, np.zeros(zeros_shape)), axis=-1)
|
1872 |
+
if not same_data:
|
1873 |
+
zeros_shape = list(y.shape[:-1]) + [nadd]
|
1874 |
+
y = np.concatenate((y, np.zeros(zeros_shape)), axis=-1)
|
1875 |
+
|
1876 |
+
# Handle detrending and window functions
|
1877 |
+
if not detrend:
|
1878 |
+
def detrend_func(d):
|
1879 |
+
return d
|
1880 |
+
elif not hasattr(detrend, '__call__'):
|
1881 |
+
def detrend_func(d):
|
1882 |
+
return _signaltools.detrend(d, type=detrend, axis=-1)
|
1883 |
+
elif axis != -1:
|
1884 |
+
# Wrap this function so that it receives a shape that it could
|
1885 |
+
# reasonably expect to receive.
|
1886 |
+
def detrend_func(d):
|
1887 |
+
d = np.moveaxis(d, -1, axis)
|
1888 |
+
d = detrend(d)
|
1889 |
+
return np.moveaxis(d, axis, -1)
|
1890 |
+
else:
|
1891 |
+
detrend_func = detrend
|
1892 |
+
|
1893 |
+
if np.result_type(win, np.complex64) != outdtype:
|
1894 |
+
win = win.astype(outdtype)
|
1895 |
+
|
1896 |
+
if scaling == 'density':
|
1897 |
+
scale = 1.0 / (fs * (win*win).sum())
|
1898 |
+
elif scaling == 'spectrum':
|
1899 |
+
scale = 1.0 / win.sum()**2
|
1900 |
+
else:
|
1901 |
+
raise ValueError('Unknown scaling: %r' % scaling)
|
1902 |
+
|
1903 |
+
if mode == 'stft':
|
1904 |
+
scale = np.sqrt(scale)
|
1905 |
+
|
1906 |
+
if return_onesided:
|
1907 |
+
if np.iscomplexobj(x):
|
1908 |
+
sides = 'twosided'
|
1909 |
+
warnings.warn('Input data is complex, switching to return_onesided=False',
|
1910 |
+
stacklevel=3)
|
1911 |
+
else:
|
1912 |
+
sides = 'onesided'
|
1913 |
+
if not same_data:
|
1914 |
+
if np.iscomplexobj(y):
|
1915 |
+
sides = 'twosided'
|
1916 |
+
warnings.warn('Input data is complex, switching to '
|
1917 |
+
'return_onesided=False',
|
1918 |
+
stacklevel=3)
|
1919 |
+
else:
|
1920 |
+
sides = 'twosided'
|
1921 |
+
|
1922 |
+
if sides == 'twosided':
|
1923 |
+
freqs = sp_fft.fftfreq(nfft, 1/fs)
|
1924 |
+
elif sides == 'onesided':
|
1925 |
+
freqs = sp_fft.rfftfreq(nfft, 1/fs)
|
1926 |
+
|
1927 |
+
# Perform the windowed FFTs
|
1928 |
+
result = _fft_helper(x, win, detrend_func, nperseg, noverlap, nfft, sides)
|
1929 |
+
|
1930 |
+
if not same_data:
|
1931 |
+
# All the same operations on the y data
|
1932 |
+
result_y = _fft_helper(y, win, detrend_func, nperseg, noverlap, nfft,
|
1933 |
+
sides)
|
1934 |
+
result = np.conjugate(result) * result_y
|
1935 |
+
elif mode == 'psd':
|
1936 |
+
result = np.conjugate(result) * result
|
1937 |
+
|
1938 |
+
result *= scale
|
1939 |
+
if sides == 'onesided' and mode == 'psd':
|
1940 |
+
if nfft % 2:
|
1941 |
+
result[..., 1:] *= 2
|
1942 |
+
else:
|
1943 |
+
# Last point is unpaired Nyquist freq point, don't double
|
1944 |
+
result[..., 1:-1] *= 2
|
1945 |
+
|
1946 |
+
time = np.arange(nperseg/2, x.shape[-1] - nperseg/2 + 1,
|
1947 |
+
nperseg - noverlap)/float(fs)
|
1948 |
+
if boundary is not None:
|
1949 |
+
time -= (nperseg/2) / fs
|
1950 |
+
|
1951 |
+
result = result.astype(outdtype)
|
1952 |
+
|
1953 |
+
# All imaginary parts are zero anyways
|
1954 |
+
if same_data and mode != 'stft':
|
1955 |
+
result = result.real
|
1956 |
+
|
1957 |
+
# Output is going to have new last axis for time/window index, so a
|
1958 |
+
# negative axis index shifts down one
|
1959 |
+
if axis < 0:
|
1960 |
+
axis -= 1
|
1961 |
+
|
1962 |
+
# Roll frequency axis back to axis where the data came from
|
1963 |
+
result = np.moveaxis(result, -1, axis)
|
1964 |
+
|
1965 |
+
return freqs, time, result
|
1966 |
+
|
1967 |
+
|
1968 |
+
def _fft_helper(x, win, detrend_func, nperseg, noverlap, nfft, sides):
|
1969 |
+
"""
|
1970 |
+
Calculate windowed FFT, for internal use by
|
1971 |
+
`scipy.signal._spectral_helper`.
|
1972 |
+
|
1973 |
+
This is a helper function that does the main FFT calculation for
|
1974 |
+
`_spectral helper`. All input validation is performed there, and the
|
1975 |
+
data axis is assumed to be the last axis of x. It is not designed to
|
1976 |
+
be called externally. The windows are not averaged over; the result
|
1977 |
+
from each window is returned.
|
1978 |
+
|
1979 |
+
Returns
|
1980 |
+
-------
|
1981 |
+
result : ndarray
|
1982 |
+
Array of FFT data
|
1983 |
+
|
1984 |
+
Notes
|
1985 |
+
-----
|
1986 |
+
Adapted from matplotlib.mlab
|
1987 |
+
|
1988 |
+
.. versionadded:: 0.16.0
|
1989 |
+
"""
|
1990 |
+
# Created sliding window view of array
|
1991 |
+
if nperseg == 1 and noverlap == 0:
|
1992 |
+
result = x[..., np.newaxis]
|
1993 |
+
else:
|
1994 |
+
step = nperseg - noverlap
|
1995 |
+
result = np.lib.stride_tricks.sliding_window_view(
|
1996 |
+
x, window_shape=nperseg, axis=-1, writeable=True
|
1997 |
+
)
|
1998 |
+
result = result[..., 0::step, :]
|
1999 |
+
|
2000 |
+
# Detrend each data segment individually
|
2001 |
+
result = detrend_func(result)
|
2002 |
+
|
2003 |
+
# Apply window by multiplication
|
2004 |
+
result = win * result
|
2005 |
+
|
2006 |
+
# Perform the fft. Acts on last axis by default. Zero-pads automatically
|
2007 |
+
if sides == 'twosided':
|
2008 |
+
func = sp_fft.fft
|
2009 |
+
else:
|
2010 |
+
result = result.real
|
2011 |
+
func = sp_fft.rfft
|
2012 |
+
result = func(result, n=nfft)
|
2013 |
+
|
2014 |
+
return result
|
2015 |
+
|
2016 |
+
|
2017 |
+
def _triage_segments(window, nperseg, input_length):
|
2018 |
+
"""
|
2019 |
+
Parses window and nperseg arguments for spectrogram and _spectral_helper.
|
2020 |
+
This is a helper function, not meant to be called externally.
|
2021 |
+
|
2022 |
+
Parameters
|
2023 |
+
----------
|
2024 |
+
window : string, tuple, or ndarray
|
2025 |
+
If window is specified by a string or tuple and nperseg is not
|
2026 |
+
specified, nperseg is set to the default of 256 and returns a window of
|
2027 |
+
that length.
|
2028 |
+
If instead the window is array_like and nperseg is not specified, then
|
2029 |
+
nperseg is set to the length of the window. A ValueError is raised if
|
2030 |
+
the user supplies both an array_like window and a value for nperseg but
|
2031 |
+
nperseg does not equal the length of the window.
|
2032 |
+
|
2033 |
+
nperseg : int
|
2034 |
+
Length of each segment
|
2035 |
+
|
2036 |
+
input_length: int
|
2037 |
+
Length of input signal, i.e. x.shape[-1]. Used to test for errors.
|
2038 |
+
|
2039 |
+
Returns
|
2040 |
+
-------
|
2041 |
+
win : ndarray
|
2042 |
+
window. If function was called with string or tuple than this will hold
|
2043 |
+
the actual array used as a window.
|
2044 |
+
|
2045 |
+
nperseg : int
|
2046 |
+
Length of each segment. If window is str or tuple, nperseg is set to
|
2047 |
+
256. If window is array_like, nperseg is set to the length of the
|
2048 |
+
window.
|
2049 |
+
"""
|
2050 |
+
# parse window; if array like, then set nperseg = win.shape
|
2051 |
+
if isinstance(window, str) or isinstance(window, tuple):
|
2052 |
+
# if nperseg not specified
|
2053 |
+
if nperseg is None:
|
2054 |
+
nperseg = 256 # then change to default
|
2055 |
+
if nperseg > input_length:
|
2056 |
+
warnings.warn(f'nperseg = {nperseg:d} is greater than input length '
|
2057 |
+
f' = {input_length:d}, using nperseg = {input_length:d}',
|
2058 |
+
stacklevel=3)
|
2059 |
+
nperseg = input_length
|
2060 |
+
win = get_window(window, nperseg)
|
2061 |
+
else:
|
2062 |
+
win = np.asarray(window)
|
2063 |
+
if len(win.shape) != 1:
|
2064 |
+
raise ValueError('window must be 1-D')
|
2065 |
+
if input_length < win.shape[-1]:
|
2066 |
+
raise ValueError('window is longer than input signal')
|
2067 |
+
if nperseg is None:
|
2068 |
+
nperseg = win.shape[0]
|
2069 |
+
elif nperseg is not None:
|
2070 |
+
if nperseg != win.shape[0]:
|
2071 |
+
raise ValueError("value specified for nperseg is different"
|
2072 |
+
" from length of window")
|
2073 |
+
return win, nperseg
|
2074 |
+
|
2075 |
+
|
2076 |
+
def _median_bias(n):
|
2077 |
+
"""
|
2078 |
+
Returns the bias of the median of a set of periodograms relative to
|
2079 |
+
the mean.
|
2080 |
+
|
2081 |
+
See Appendix B from [1]_ for details.
|
2082 |
+
|
2083 |
+
Parameters
|
2084 |
+
----------
|
2085 |
+
n : int
|
2086 |
+
Numbers of periodograms being averaged.
|
2087 |
+
|
2088 |
+
Returns
|
2089 |
+
-------
|
2090 |
+
bias : float
|
2091 |
+
Calculated bias.
|
2092 |
+
|
2093 |
+
References
|
2094 |
+
----------
|
2095 |
+
.. [1] B. Allen, W.G. Anderson, P.R. Brady, D.A. Brown, J.D.E. Creighton.
|
2096 |
+
"FINDCHIRP: an algorithm for detection of gravitational waves from
|
2097 |
+
inspiraling compact binaries", Physical Review D 85, 2012,
|
2098 |
+
:arxiv:`gr-qc/0509116`
|
2099 |
+
"""
|
2100 |
+
ii_2 = 2 * np.arange(1., (n-1) // 2 + 1)
|
2101 |
+
return 1 + np.sum(1. / (ii_2 + 1) - 1. / ii_2)
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/_upfirdn_apply.cpython-310-x86_64-linux-gnu.so
ADDED
Binary file (395 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/signal/ltisys.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file is not meant for public use and will be removed in SciPy v2.0.0.
|
2 |
+
# Use the `scipy.signal` namespace for importing the functions
|
3 |
+
# included below.
|
4 |
+
|
5 |
+
from scipy._lib.deprecation import _sub_module_deprecation
|
6 |
+
|
7 |
+
__all__ = [ # noqa: F822
|
8 |
+
'lti', 'dlti', 'TransferFunction', 'ZerosPolesGain', 'StateSpace',
|
9 |
+
'lsim', 'impulse', 'step', 'bode',
|
10 |
+
'freqresp', 'place_poles', 'dlsim', 'dstep', 'dimpulse',
|
11 |
+
'dfreqresp', 'dbode', 's_qr', 'linalg',
|
12 |
+
'tf2zpk', 'zpk2tf', 'normalize', 'freqs',
|
13 |
+
'freqz', 'freqs_zpk', 'freqz_zpk', 'tf2ss', 'abcd_normalize',
|
14 |
+
'ss2tf', 'zpk2ss', 'ss2zpk', 'cont2discrete', 'atleast_1d',
|
15 |
+
'squeeze', 'transpose', 'linspace',
|
16 |
+
'LinearTimeInvariant', 'TransferFunctionContinuous',
|
17 |
+
'TransferFunctionDiscrete', 'ZerosPolesGainContinuous',
|
18 |
+
'ZerosPolesGainDiscrete', 'StateSpaceContinuous',
|
19 |
+
'StateSpaceDiscrete', 'Bunch'
|
20 |
+
]
|
21 |
+
|
22 |
+
|
23 |
+
def __dir__():
|
24 |
+
return __all__
|
25 |
+
|
26 |
+
|
27 |
+
def __getattr__(name):
|
28 |
+
return _sub_module_deprecation(sub_package="signal", module="ltisys",
|
29 |
+
private_modules=["_ltisys"], all=__all__,
|
30 |
+
attribute=name)
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (3.97 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/_plotutils.cpython-310.pyc
ADDED
Binary file (6.67 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/_procrustes.cpython-310.pyc
ADDED
Binary file (4.27 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/_spherical_voronoi.cpython-310.pyc
ADDED
Binary file (11.9 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/ckdtree.cpython-310.pyc
ADDED
Binary file (676 Bytes). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/__pycache__/distance.cpython-310.pyc
ADDED
Binary file (80.5 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__init__.py
ADDED
File without changes
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (184 Bytes). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test__plotutils.cpython-310.pyc
ADDED
Binary file (2.87 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test__procrustes.cpython-310.pyc
ADDED
Binary file (3.73 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_distance.cpython-310.pyc
ADDED
Binary file (70.1 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_hausdorff.cpython-310.pyc
ADDED
Binary file (5.36 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_kdtree.cpython-310.pyc
ADDED
Binary file (50 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_qhull.cpython-310.pyc
ADDED
Binary file (32.9 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_slerp.cpython-310.pyc
ADDED
Binary file (9.33 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/__pycache__/test_spherical_voronoi.cpython-310.pyc
ADDED
Binary file (13.6 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/cdist-X1.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1.147593763490969421e-01 8.926156143344999849e-01 1.437758624645746330e-02 1.803435962879929022e-02 5.533046214065578949e-01 5.554315640747428118e-01 4.497546637814608950e-02 4.438089247948049376e-01 7.984582810220538507e-01 2.752880789161644692e-01 1.344667112315823809e-01 9.230479561452992199e-01 6.040471462941819913e-01 3.797251652770228247e-01 4.316042735592399149e-01 5.312356915348823705e-01 4.348143005129563310e-01 3.111531488508799681e-01 9.531194313908697424e-04 8.212995023500069269e-02 6.689953269869852726e-01 9.914864535288493430e-01 8.037556036341153565e-01
|
2 |
+
9.608925123801395074e-01 2.974451233678974127e-01 9.001110330654185088e-01 5.824163330415995654e-01 7.308574928293812834e-01 2.276154562412870952e-01 7.306791076039623745e-01 8.677244866905511333e-01 9.160806456176984192e-01 6.157216959991280714e-01 5.149053524695440531e-01 3.056427344890983999e-01 9.790557366933895223e-01 4.484995861076724877e-01 4.776550391081165747e-01 7.210436977670631187e-01 9.136399501661039979e-01 4.260275733550000776e-02 5.943900041968954717e-01 3.864571606342745991e-01 9.442027665110838131e-01 4.779949058608601309e-02 6.107551944250865228e-01
|
3 |
+
3.297286578103622023e-01 5.980207401936733502e-01 3.673301293561567205e-01 2.585830520887681949e-01 4.660558746104259686e-01 6.083795956610364986e-01 4.535206368070313632e-01 6.873989778785424276e-01 5.130152688495458468e-01 7.665877846542720198e-01 3.444402973525138023e-01 3.583658123644906102e-02 7.924818220986856732e-01 8.746685720522412444e-01 3.010105569182431884e-01 6.012239357385538163e-01 6.233737362204671006e-01 4.830438698668915176e-01 2.317286885842551047e-02 7.585989958123050547e-01 7.108257632278830451e-01 1.551024884178199281e-01 2.665485998155288083e-01
|
4 |
+
2.456278068903017253e-02 4.148739837711815648e-01 1.986372227934196655e-01 6.920408530298168825e-01 1.003067576685774398e-01 7.421560456480125190e-01 1.808453980608998313e-01 4.251297882537475870e-01 6.773002683522370004e-01 4.084108792570182445e-01 7.462888013191590897e-01 8.069930220529277776e-01 9.211110587681808903e-01 4.141491046181076108e-01 7.486318689260342829e-01 9.515405507589296263e-01 4.634288892577109742e-03 8.027593488166355762e-01 3.010346805217798405e-01 8.663248877242523127e-01 2.479968181181605447e-01 5.619851096054278017e-01 3.903886764590250857e-01
|
5 |
+
7.122019976035700584e-01 6.188878051047785878e-01 7.290897087051201320e-01 6.334802157757637442e-01 5.523084734954342156e-01 5.614937129563645213e-01 2.496741051791574462e-01 5.972227939599233926e-01 1.786590597761109622e-01 2.609525984850900038e-01 7.210438943286010538e-01 2.211429064605652250e-01 9.140497572472672250e-02 1.430242193668443962e-01 7.856446942916397447e-01 4.635256358156553125e-01 5.278744289813760426e-01 3.702808015407184072e-01 5.527073830480792038e-01 6.370732917599846168e-01 9.953487928925482953e-01 3.021789770611936765e-01 3.354901923998221402e-02
|
6 |
+
6.509638560895427695e-01 8.387598220902757751e-01 7.761375971745763103e-01 1.481627639227802717e-01 3.529474982902305324e-01 4.883093646287851586e-01 9.652923033658690199e-01 9.500680513565308294e-01 3.061885005078281985e-01 7.271902818906019750e-01 2.358962978196710303e-03 7.359889703223099211e-01 8.988893768074724955e-01 4.135279653937307121e-02 8.516441856688283796e-01 4.889597623270667270e-01 5.575909822114655245e-01 9.010853652261575641e-01 2.912844516556202246e-01 9.088759383368658629e-01 8.104351227460024898e-01 8.080695436776826890e-01 1.430530913253185155e-01
|
7 |
+
8.048001196608134400e-01 3.066089444418462762e-02 9.021887554292090661e-01 6.154331491807940591e-02 1.378912575206647784e-02 5.775720193142440673e-01 1.219298963069791464e-01 1.883270243412101808e-01 5.569262398688379356e-02 8.964817777510125651e-02 7.977092785346929782e-01 4.878149375226197293e-01 4.511973131518809410e-02 1.858690046801604323e-01 6.947686471083162063e-01 5.884058794291086025e-01 8.638884676612634816e-01 3.855470871341656336e-01 3.495049047300468059e-01 2.767740932353948136e-01 4.731087031714035218e-01 6.679001673437914288e-01 7.502944200696660682e-01
|
8 |
+
6.527328264244687261e-01 8.289483383553154505e-01 9.179741348282299818e-01 1.065639864466713105e-01 6.253616929058514184e-01 5.927750325266062381e-01 3.039157425463192563e-01 2.452766763359194302e-01 6.514027700704632107e-01 5.529218485487964463e-01 4.941158239308394151e-01 6.605306467722642516e-01 2.273688037050677346e-01 4.282616592244774534e-01 2.956128257930247250e-01 1.154803628237965896e-01 9.228220410235263849e-01 6.663525307676617659e-01 1.908852615936970087e-01 9.921383408926374159e-01 4.988716450388516188e-01 1.014900352736023414e-01 3.363930180244284474e-01
|
9 |
+
2.914369076275757919e-01 5.196673601143533272e-01 7.420144907858341465e-01 1.768984185504740569e-01 5.296766993228564369e-01 5.922023566159900776e-01 5.965161262020234334e-01 3.810272333046110793e-01 8.368797246118340194e-01 7.896422363801189892e-01 9.655797561098209414e-01 4.430034032346981121e-01 2.780869795706976122e-01 3.047310845416009162e-01 8.051138863500326703e-01 6.731468634690835895e-01 4.743383036815584930e-01 9.530709614322225853e-01 7.753587619850917934e-01 2.801137109357491051e-01 6.182543660889736614e-01 5.005218857766725593e-01 9.071447804755052857e-01
|
10 |
+
2.075071644012620453e-01 4.834950086973934802e-01 3.037011473860764532e-01 6.476084284887700937e-01 8.107195771564194020e-01 7.869075869075803364e-01 6.851234019375299633e-01 3.544187468104398331e-02 4.847673235908021017e-01 5.690262846164507726e-01 1.663354142616256803e-01 9.692796809752548537e-01 4.133441725866372485e-01 6.729167604487583665e-01 3.998813427407297283e-01 8.272617414104491695e-01 2.129248316324727774e-01 6.517004761357130249e-01 7.363013506605019520e-01 4.072375306356985636e-01 4.463336683526665238e-01 5.485059309728204102e-01 1.981745754527846071e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/cdist-X2.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
7.680465556300619667e-02 4.675022344069014180e-01 8.955498989131543963e-01 3.816236071436276411e-01 1.109030077070989329e-01 2.318928815459808668e-02 7.477394240984251983e-01 1.202289789304434864e-01 8.007290497575981769e-01 6.795195698871731027e-01 6.568225762396605605e-01 2.231475263228478445e-01 7.064624077661341151e-02 1.081656666815267176e-02 1.592069359090128033e-01 1.363392203645097389e-01 9.277020735447568667e-01 8.103136564528209407e-01 5.229467676276455812e-02 7.708020259874025504e-01 6.527954747473352359e-02 5.516397414886525796e-01 3.653371861367954443e-01
|
2 |
+
8.144399106025798085e-01 7.731852525462976633e-01 6.909477620673205589e-01 9.696063817000286633e-01 4.297887511677249694e-01 6.989600553425188156e-01 7.310201335033380543e-01 3.135256147868910048e-01 5.715578037275241829e-01 3.935000744675094531e-01 2.057715781268398825e-01 5.892508589665171881e-01 8.512951599236765476e-01 9.569808799061578775e-01 6.164885878024699561e-01 4.714185430004367294e-01 6.128831737628155363e-01 6.641799309623502845e-01 6.001985185338730711e-01 4.231922889723856995e-01 7.605249308075449077e-01 1.064530958018087281e-01 6.306470691957204444e-01
|
3 |
+
4.265470127256254518e-01 5.933766716280767239e-01 3.698589270536845053e-02 2.173799740537294412e-01 3.032679325475639009e-01 4.271831790058847611e-01 1.828944535901013690e-01 4.772333422710156592e-01 2.564773455194128138e-01 7.120329875362141347e-01 8.952243430110462530e-01 1.808777012183288013e-01 3.612151871458374464e-01 3.960999167923041631e-01 1.821669970670747318e-02 8.835474857189200559e-01 1.353104648821573663e-01 3.457291739160937016e-01 1.126467375304566199e-01 4.107293162402323450e-01 4.051719311053743056e-01 4.007382985250427243e-01 1.286905671428811848e-01
|
4 |
+
2.910657003883979632e-01 9.616259180685315933e-03 2.033032441536681834e-01 1.096599110293863255e-01 4.191101704605176836e-01 5.462131536027151624e-01 8.393047907010142694e-01 9.046805198676335369e-01 7.009863472176891541e-01 2.508215985039629059e-01 6.754410796667598138e-01 6.740895474032024826e-01 1.358993708621679675e-01 8.219861775211464439e-01 6.322220445623235596e-01 2.766813559002430090e-01 6.575983861590951607e-01 9.515869708336625044e-01 8.654526462353933081e-01 3.450245117834797037e-01 5.649032890631299209e-01 4.717687914789682191e-01 3.296483580510030098e-01
|
5 |
+
9.172477457635394016e-01 3.057396583041891436e-01 7.335332344225760082e-01 8.370236206345178509e-01 3.765464253115927695e-01 5.089680319287778199e-01 1.202325719268168003e-01 9.717771065272349240e-01 5.907820104019682050e-01 9.809211614977710880e-01 9.064285003671219698e-01 8.848841466121748489e-01 2.043407730734815297e-01 9.157600394927275511e-01 4.532260315147775831e-01 4.241077335005828397e-01 1.751730149568804240e-01 4.090412146081819911e-01 3.632197861847064058e-02 5.832539334970230360e-01 4.041848151536805434e-01 3.603643989086504629e-01 1.838411383882069261e-01
|
6 |
+
2.508806403290032572e-01 4.381403985282813496e-01 4.694787405018008286e-02 6.353900562024634713e-01 1.200813444244532846e-01 6.072397042913001419e-01 9.937255904754030977e-01 4.916670237677555066e-01 3.473845913923001572e-01 3.526875922864345370e-01 5.448595548197197047e-01 2.245096010156972799e-01 9.003258279804994269e-01 3.534560469735994470e-01 2.989266066346342177e-01 4.621024982808636938e-01 9.626538866576676012e-01 9.791401720716153001e-01 7.138514287330390840e-01 9.832862333928654719e-01 3.233999591031431198e-01 5.406467224926423398e-01 9.581890295057201579e-01
|
7 |
+
5.210583601680578436e-01 4.598159993059653949e-01 2.111497132057748027e-01 5.949977700916546652e-01 6.342618461422359077e-01 9.888228769705599275e-01 6.096770711536318998e-01 7.548431368960863974e-01 7.490858664860100546e-01 3.186213496546415058e-01 7.895687083231245351e-01 4.178326793268141159e-01 8.095818334534051752e-01 7.886271673523481684e-01 4.038905626506847923e-01 3.652649247094948981e-01 8.267205959224892542e-01 6.433617243328785262e-01 3.117681563249452559e-01 9.675995575054980868e-01 3.675673836358472890e-01 5.863757289184046151e-01 9.099029857959717305e-02
|
8 |
+
4.024573981231733821e-01 3.578997554002771864e-01 3.519299868071553705e-01 7.417747693762357653e-01 2.963713903285800644e-01 9.602967989298948348e-01 3.811392331739601458e-01 5.493237898295448840e-01 6.835113342793640578e-01 2.304506220807415184e-01 3.727299857731285471e-01 5.450263991912108752e-01 6.951521210987908761e-01 6.474582745861203747e-01 6.316089475403589004e-01 5.672043967425510758e-02 9.034937506977609445e-01 2.332567550780038079e-01 1.096955741449157085e-02 8.870663813493575578e-01 4.384385452180562526e-01 7.100898998169548060e-01 3.245358176196319056e-01
|
9 |
+
9.162009194452818139e-01 5.572224742426723498e-02 3.445910686865658601e-01 9.683564008127462097e-01 9.375063149031520604e-01 9.128188852869822956e-02 9.613605414326487075e-01 5.298598697556915482e-01 6.724799695520149445e-01 1.269103938571825019e-02 1.008406153387807480e-01 8.951105272379104028e-01 1.585460318853607609e-01 6.739986455059543413e-01 5.345419321702655768e-01 6.248843899572337213e-01 3.050288488994817859e-01 1.423645553465189284e-01 1.802121190541096096e-01 9.474646822694763326e-01 2.345716438587298613e-01 9.688281784764296578e-01 1.845165243240991515e-01
|
10 |
+
2.548297646910531178e-01 2.580877375379494465e-01 1.355482532666937301e-01 6.478812986505504412e-01 9.971695982152032345e-01 2.606721082477282403e-01 5.483439686378906996e-01 4.409612606704470528e-01 4.396442074915688503e-01 7.414262832597111608e-01 7.308840725375539416e-01 8.072095530497225280e-02 6.829509968656330976e-01 5.700030854230387911e-01 3.801845336730320657e-01 2.481059916867158766e-01 3.977295094395927322e-03 5.749480512407895150e-01 4.112033136603401307e-01 8.676159710377848722e-01 9.062646588480167686e-01 3.326691167317923359e-01 8.498307982774666591e-01
|
11 |
+
4.464338109330643345e-01 8.546516760817471914e-01 7.384800352329814466e-01 3.692485164984804502e-02 2.915662689505471583e-02 9.010049994217171898e-01 8.622900253010918892e-01 9.786230638032608065e-01 6.546824077297251909e-01 6.342297560006789903e-01 2.230339826582647955e-01 7.658846744185553446e-01 4.603043831539479491e-01 2.017100469861691225e-01 4.891590639893540482e-01 1.937140918314912419e-01 8.161582138652878626e-01 5.597293607114051106e-02 8.423261093326828153e-02 5.105392204475533990e-02 8.234193902673621057e-01 1.784268309975372002e-01 9.118997881986501408e-02
|
12 |
+
8.588746913421980711e-01 1.479641118621310980e-02 1.375875301146138874e-01 7.533888774725254756e-01 5.782592791549248101e-01 9.128573037619659436e-01 1.831275762880391067e-01 3.471382864827737835e-01 4.859524740929310749e-02 8.955146541561730400e-01 4.787220791101074457e-01 4.222803577759057791e-01 8.469923964908064873e-01 6.300290047587608910e-02 1.020873237837905956e-01 3.585612487182909813e-02 6.320107119904569970e-01 5.891245970008752719e-01 1.104698053665007507e-01 4.233226558073774903e-01 4.432217054386708988e-01 2.864765416628194394e-01 2.489777211814803159e-02
|
13 |
+
5.343810659756068615e-01 4.829076396403546578e-01 8.364480888953172988e-01 8.931374995414760321e-01 6.034161442354715188e-01 3.578336000768178593e-03 4.100579775972763574e-01 3.968667908067096128e-01 5.897163653686778861e-01 3.003241263928478899e-01 2.520935203143799264e-01 3.112129371563532310e-02 9.052865295974613646e-01 1.172285124002711010e-01 4.840001666149388315e-01 3.424620676348436588e-01 5.526057133826853818e-01 6.346139530261846184e-01 5.747945930485597321e-01 1.389915612177697879e-01 2.413801217666421417e-01 7.829900796662081497e-01 7.213528084845653998e-01
|
14 |
+
9.384509283406079483e-01 6.303019601671526750e-01 1.787921522728125323e-01 1.556003868047917127e-02 5.662397078816850948e-01 3.437473614806091371e-01 8.615844972800188462e-01 7.624380237306396246e-01 1.096468347898514883e-01 1.276566836610887323e-01 8.479188493443535757e-01 3.634713454428405432e-01 7.478112314318967613e-01 9.856395696968375253e-01 6.250293654177319080e-02 1.919327272501809567e-01 1.415594476031050153e-01 7.224057351041784925e-01 8.452145259310355208e-01 5.434318833772002755e-01 5.177620959731277228e-02 3.358977598185840518e-01 2.542654881527960375e-01
|
15 |
+
4.800909104006243489e-01 3.651345393613150137e-01 3.657093052788148446e-01 8.579662326651369408e-01 5.787694361240260932e-01 6.491966196891312268e-01 3.252508517294879775e-01 8.639694334693422961e-01 3.028097078756678551e-01 6.295814666338699350e-01 7.305627351548695803e-01 6.975931849120264872e-03 8.321205159004851915e-01 2.681809305821257761e-01 3.628869474597150591e-01 9.598981434716586936e-01 5.947913523332928332e-01 7.794864238003402779e-01 2.819511239444029149e-01 5.134200958476284882e-01 7.284684743064278045e-01 3.099571109539331903e-01 1.502222882866774967e-01
|
16 |
+
2.463382654375219083e-01 4.465700737264240994e-01 7.180855317941433613e-01 5.056099420785193921e-01 6.182117344332578313e-01 2.370453793561340117e-01 9.831748018047525850e-01 6.397098184531551102e-01 8.260469782208745837e-02 7.474671691560941245e-01 9.963429983418570224e-02 5.450078811081275898e-01 5.370188678062637333e-02 2.774024442708808991e-01 2.082643088545442778e-01 2.704155352788065736e-01 7.225035580445194894e-01 4.866791976239246420e-01 1.357043111201584606e-01 7.911335827987711067e-01 7.278977102006007893e-01 6.880892094410231419e-01 1.029231496520791600e-01
|
17 |
+
6.901796117735281566e-01 1.558248977395644275e-01 4.241818789360329855e-01 5.055658246392458199e-01 1.756288758075611467e-01 4.215083703818177652e-01 7.809231602323289945e-01 1.170053878686481141e-01 6.497026323614403243e-01 5.733120641440232479e-01 4.407703406152092551e-01 5.608677124532297498e-01 7.471045703286000039e-01 3.334604336022076732e-01 8.927208811415126011e-01 9.794565286182396191e-01 9.621542824973521313e-01 3.945825239405253981e-01 8.338963875792834157e-01 9.310552325082104286e-01 7.688283033784242271e-01 3.798823731047119567e-01 1.459993613028365278e-02
|
18 |
+
7.848623555505630511e-01 2.681039365355797344e-03 7.833208051794043891e-01 8.184381915171493604e-01 4.682581645582317709e-01 2.391069309436419932e-01 1.765377537168698607e-01 9.863494676539893424e-01 4.378412300863872009e-01 7.494505491149090481e-01 1.942180356195394308e-01 9.981402467222395547e-01 7.992190944052800505e-01 1.350875702852057936e-01 4.950149186748543650e-01 7.243422481248201761e-01 3.544596746353472216e-01 8.320192561472177228e-01 9.776840296475269865e-01 7.733852731914863110e-01 2.305732998099923048e-01 9.746878189802981041e-01 7.747723331200035979e-01
|
19 |
+
6.521099013127149568e-01 5.452399443648201505e-01 8.146707517183656710e-01 3.827256063695345656e-01 7.954832091744263867e-01 7.834427643148527132e-01 9.661317930643520402e-02 9.215673965718058636e-01 4.914305728788055383e-01 4.105628408027649501e-01 9.844647830893304974e-02 3.974831165301851987e-01 3.857608898053827007e-01 5.520210781401946321e-01 3.445787541654143915e-03 4.552922057017416702e-01 7.456544561760444223e-01 4.753985092154335845e-01 2.821385239833401615e-01 7.560136035104459973e-01 8.453142510471420845e-01 6.679627143276523071e-01 6.910882868284401459e-01
|
20 |
+
8.526493480446283302e-01 1.183917973068240315e-01 6.163988861865119517e-01 5.751899460059114455e-01 1.638797964925038375e-01 8.214597298784013235e-01 5.424670654187370156e-01 1.806631819658732763e-01 9.268107278221827672e-01 4.127397378597359445e-01 7.529877485901653733e-01 1.714251090083847018e-01 2.601487784245806179e-01 2.028326156742237263e-01 5.299879450122358948e-01 7.587877062981395193e-01 4.070738595375062996e-01 3.546903049793261875e-01 8.695365138547607176e-01 1.447085661525142619e-01 3.193366245820845606e-01 8.797841086211429795e-01 2.666562188639977071e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/iris.txt
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
5.099999999999999645e+00 3.500000000000000000e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
2 |
+
4.900000000000000355e+00 3.000000000000000000e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
3 |
+
4.700000000000000178e+00 3.200000000000000178e+00 1.300000000000000044e+00 2.000000000000000111e-01
|
4 |
+
4.599999999999999645e+00 3.100000000000000089e+00 1.500000000000000000e+00 2.000000000000000111e-01
|
5 |
+
5.000000000000000000e+00 3.600000000000000089e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
6 |
+
5.400000000000000355e+00 3.899999999999999911e+00 1.699999999999999956e+00 4.000000000000000222e-01
|
7 |
+
4.599999999999999645e+00 3.399999999999999911e+00 1.399999999999999911e+00 2.999999999999999889e-01
|
8 |
+
5.000000000000000000e+00 3.399999999999999911e+00 1.500000000000000000e+00 2.000000000000000111e-01
|
9 |
+
4.400000000000000355e+00 2.899999999999999911e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
10 |
+
4.900000000000000355e+00 3.100000000000000089e+00 1.500000000000000000e+00 1.000000000000000056e-01
|
11 |
+
5.400000000000000355e+00 3.700000000000000178e+00 1.500000000000000000e+00 2.000000000000000111e-01
|
12 |
+
4.799999999999999822e+00 3.399999999999999911e+00 1.600000000000000089e+00 2.000000000000000111e-01
|
13 |
+
4.799999999999999822e+00 3.000000000000000000e+00 1.399999999999999911e+00 1.000000000000000056e-01
|
14 |
+
4.299999999999999822e+00 3.000000000000000000e+00 1.100000000000000089e+00 1.000000000000000056e-01
|
15 |
+
5.799999999999999822e+00 4.000000000000000000e+00 1.199999999999999956e+00 2.000000000000000111e-01
|
16 |
+
5.700000000000000178e+00 4.400000000000000355e+00 1.500000000000000000e+00 4.000000000000000222e-01
|
17 |
+
5.400000000000000355e+00 3.899999999999999911e+00 1.300000000000000044e+00 4.000000000000000222e-01
|
18 |
+
5.099999999999999645e+00 3.500000000000000000e+00 1.399999999999999911e+00 2.999999999999999889e-01
|
19 |
+
5.700000000000000178e+00 3.799999999999999822e+00 1.699999999999999956e+00 2.999999999999999889e-01
|
20 |
+
5.099999999999999645e+00 3.799999999999999822e+00 1.500000000000000000e+00 2.999999999999999889e-01
|
21 |
+
5.400000000000000355e+00 3.399999999999999911e+00 1.699999999999999956e+00 2.000000000000000111e-01
|
22 |
+
5.099999999999999645e+00 3.700000000000000178e+00 1.500000000000000000e+00 4.000000000000000222e-01
|
23 |
+
4.599999999999999645e+00 3.600000000000000089e+00 1.000000000000000000e+00 2.000000000000000111e-01
|
24 |
+
5.099999999999999645e+00 3.299999999999999822e+00 1.699999999999999956e+00 5.000000000000000000e-01
|
25 |
+
4.799999999999999822e+00 3.399999999999999911e+00 1.899999999999999911e+00 2.000000000000000111e-01
|
26 |
+
5.000000000000000000e+00 3.000000000000000000e+00 1.600000000000000089e+00 2.000000000000000111e-01
|
27 |
+
5.000000000000000000e+00 3.399999999999999911e+00 1.600000000000000089e+00 4.000000000000000222e-01
|
28 |
+
5.200000000000000178e+00 3.500000000000000000e+00 1.500000000000000000e+00 2.000000000000000111e-01
|
29 |
+
5.200000000000000178e+00 3.399999999999999911e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
30 |
+
4.700000000000000178e+00 3.200000000000000178e+00 1.600000000000000089e+00 2.000000000000000111e-01
|
31 |
+
4.799999999999999822e+00 3.100000000000000089e+00 1.600000000000000089e+00 2.000000000000000111e-01
|
32 |
+
5.400000000000000355e+00 3.399999999999999911e+00 1.500000000000000000e+00 4.000000000000000222e-01
|
33 |
+
5.200000000000000178e+00 4.099999999999999645e+00 1.500000000000000000e+00 1.000000000000000056e-01
|
34 |
+
5.500000000000000000e+00 4.200000000000000178e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
35 |
+
4.900000000000000355e+00 3.100000000000000089e+00 1.500000000000000000e+00 1.000000000000000056e-01
|
36 |
+
5.000000000000000000e+00 3.200000000000000178e+00 1.199999999999999956e+00 2.000000000000000111e-01
|
37 |
+
5.500000000000000000e+00 3.500000000000000000e+00 1.300000000000000044e+00 2.000000000000000111e-01
|
38 |
+
4.900000000000000355e+00 3.100000000000000089e+00 1.500000000000000000e+00 1.000000000000000056e-01
|
39 |
+
4.400000000000000355e+00 3.000000000000000000e+00 1.300000000000000044e+00 2.000000000000000111e-01
|
40 |
+
5.099999999999999645e+00 3.399999999999999911e+00 1.500000000000000000e+00 2.000000000000000111e-01
|
41 |
+
5.000000000000000000e+00 3.500000000000000000e+00 1.300000000000000044e+00 2.999999999999999889e-01
|
42 |
+
4.500000000000000000e+00 2.299999999999999822e+00 1.300000000000000044e+00 2.999999999999999889e-01
|
43 |
+
4.400000000000000355e+00 3.200000000000000178e+00 1.300000000000000044e+00 2.000000000000000111e-01
|
44 |
+
5.000000000000000000e+00 3.500000000000000000e+00 1.600000000000000089e+00 5.999999999999999778e-01
|
45 |
+
5.099999999999999645e+00 3.799999999999999822e+00 1.899999999999999911e+00 4.000000000000000222e-01
|
46 |
+
4.799999999999999822e+00 3.000000000000000000e+00 1.399999999999999911e+00 2.999999999999999889e-01
|
47 |
+
5.099999999999999645e+00 3.799999999999999822e+00 1.600000000000000089e+00 2.000000000000000111e-01
|
48 |
+
4.599999999999999645e+00 3.200000000000000178e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
49 |
+
5.299999999999999822e+00 3.700000000000000178e+00 1.500000000000000000e+00 2.000000000000000111e-01
|
50 |
+
5.000000000000000000e+00 3.299999999999999822e+00 1.399999999999999911e+00 2.000000000000000111e-01
|
51 |
+
7.000000000000000000e+00 3.200000000000000178e+00 4.700000000000000178e+00 1.399999999999999911e+00
|
52 |
+
6.400000000000000355e+00 3.200000000000000178e+00 4.500000000000000000e+00 1.500000000000000000e+00
|
53 |
+
6.900000000000000355e+00 3.100000000000000089e+00 4.900000000000000355e+00 1.500000000000000000e+00
|
54 |
+
5.500000000000000000e+00 2.299999999999999822e+00 4.000000000000000000e+00 1.300000000000000044e+00
|
55 |
+
6.500000000000000000e+00 2.799999999999999822e+00 4.599999999999999645e+00 1.500000000000000000e+00
|
56 |
+
5.700000000000000178e+00 2.799999999999999822e+00 4.500000000000000000e+00 1.300000000000000044e+00
|
57 |
+
6.299999999999999822e+00 3.299999999999999822e+00 4.700000000000000178e+00 1.600000000000000089e+00
|
58 |
+
4.900000000000000355e+00 2.399999999999999911e+00 3.299999999999999822e+00 1.000000000000000000e+00
|
59 |
+
6.599999999999999645e+00 2.899999999999999911e+00 4.599999999999999645e+00 1.300000000000000044e+00
|
60 |
+
5.200000000000000178e+00 2.700000000000000178e+00 3.899999999999999911e+00 1.399999999999999911e+00
|
61 |
+
5.000000000000000000e+00 2.000000000000000000e+00 3.500000000000000000e+00 1.000000000000000000e+00
|
62 |
+
5.900000000000000355e+00 3.000000000000000000e+00 4.200000000000000178e+00 1.500000000000000000e+00
|
63 |
+
6.000000000000000000e+00 2.200000000000000178e+00 4.000000000000000000e+00 1.000000000000000000e+00
|
64 |
+
6.099999999999999645e+00 2.899999999999999911e+00 4.700000000000000178e+00 1.399999999999999911e+00
|
65 |
+
5.599999999999999645e+00 2.899999999999999911e+00 3.600000000000000089e+00 1.300000000000000044e+00
|
66 |
+
6.700000000000000178e+00 3.100000000000000089e+00 4.400000000000000355e+00 1.399999999999999911e+00
|
67 |
+
5.599999999999999645e+00 3.000000000000000000e+00 4.500000000000000000e+00 1.500000000000000000e+00
|
68 |
+
5.799999999999999822e+00 2.700000000000000178e+00 4.099999999999999645e+00 1.000000000000000000e+00
|
69 |
+
6.200000000000000178e+00 2.200000000000000178e+00 4.500000000000000000e+00 1.500000000000000000e+00
|
70 |
+
5.599999999999999645e+00 2.500000000000000000e+00 3.899999999999999911e+00 1.100000000000000089e+00
|
71 |
+
5.900000000000000355e+00 3.200000000000000178e+00 4.799999999999999822e+00 1.800000000000000044e+00
|
72 |
+
6.099999999999999645e+00 2.799999999999999822e+00 4.000000000000000000e+00 1.300000000000000044e+00
|
73 |
+
6.299999999999999822e+00 2.500000000000000000e+00 4.900000000000000355e+00 1.500000000000000000e+00
|
74 |
+
6.099999999999999645e+00 2.799999999999999822e+00 4.700000000000000178e+00 1.199999999999999956e+00
|
75 |
+
6.400000000000000355e+00 2.899999999999999911e+00 4.299999999999999822e+00 1.300000000000000044e+00
|
76 |
+
6.599999999999999645e+00 3.000000000000000000e+00 4.400000000000000355e+00 1.399999999999999911e+00
|
77 |
+
6.799999999999999822e+00 2.799999999999999822e+00 4.799999999999999822e+00 1.399999999999999911e+00
|
78 |
+
6.700000000000000178e+00 3.000000000000000000e+00 5.000000000000000000e+00 1.699999999999999956e+00
|
79 |
+
6.000000000000000000e+00 2.899999999999999911e+00 4.500000000000000000e+00 1.500000000000000000e+00
|
80 |
+
5.700000000000000178e+00 2.600000000000000089e+00 3.500000000000000000e+00 1.000000000000000000e+00
|
81 |
+
5.500000000000000000e+00 2.399999999999999911e+00 3.799999999999999822e+00 1.100000000000000089e+00
|
82 |
+
5.500000000000000000e+00 2.399999999999999911e+00 3.700000000000000178e+00 1.000000000000000000e+00
|
83 |
+
5.799999999999999822e+00 2.700000000000000178e+00 3.899999999999999911e+00 1.199999999999999956e+00
|
84 |
+
6.000000000000000000e+00 2.700000000000000178e+00 5.099999999999999645e+00 1.600000000000000089e+00
|
85 |
+
5.400000000000000355e+00 3.000000000000000000e+00 4.500000000000000000e+00 1.500000000000000000e+00
|
86 |
+
6.000000000000000000e+00 3.399999999999999911e+00 4.500000000000000000e+00 1.600000000000000089e+00
|
87 |
+
6.700000000000000178e+00 3.100000000000000089e+00 4.700000000000000178e+00 1.500000000000000000e+00
|
88 |
+
6.299999999999999822e+00 2.299999999999999822e+00 4.400000000000000355e+00 1.300000000000000044e+00
|
89 |
+
5.599999999999999645e+00 3.000000000000000000e+00 4.099999999999999645e+00 1.300000000000000044e+00
|
90 |
+
5.500000000000000000e+00 2.500000000000000000e+00 4.000000000000000000e+00 1.300000000000000044e+00
|
91 |
+
5.500000000000000000e+00 2.600000000000000089e+00 4.400000000000000355e+00 1.199999999999999956e+00
|
92 |
+
6.099999999999999645e+00 3.000000000000000000e+00 4.599999999999999645e+00 1.399999999999999911e+00
|
93 |
+
5.799999999999999822e+00 2.600000000000000089e+00 4.000000000000000000e+00 1.199999999999999956e+00
|
94 |
+
5.000000000000000000e+00 2.299999999999999822e+00 3.299999999999999822e+00 1.000000000000000000e+00
|
95 |
+
5.599999999999999645e+00 2.700000000000000178e+00 4.200000000000000178e+00 1.300000000000000044e+00
|
96 |
+
5.700000000000000178e+00 3.000000000000000000e+00 4.200000000000000178e+00 1.199999999999999956e+00
|
97 |
+
5.700000000000000178e+00 2.899999999999999911e+00 4.200000000000000178e+00 1.300000000000000044e+00
|
98 |
+
6.200000000000000178e+00 2.899999999999999911e+00 4.299999999999999822e+00 1.300000000000000044e+00
|
99 |
+
5.099999999999999645e+00 2.500000000000000000e+00 3.000000000000000000e+00 1.100000000000000089e+00
|
100 |
+
5.700000000000000178e+00 2.799999999999999822e+00 4.099999999999999645e+00 1.300000000000000044e+00
|
101 |
+
6.299999999999999822e+00 3.299999999999999822e+00 6.000000000000000000e+00 2.500000000000000000e+00
|
102 |
+
5.799999999999999822e+00 2.700000000000000178e+00 5.099999999999999645e+00 1.899999999999999911e+00
|
103 |
+
7.099999999999999645e+00 3.000000000000000000e+00 5.900000000000000355e+00 2.100000000000000089e+00
|
104 |
+
6.299999999999999822e+00 2.899999999999999911e+00 5.599999999999999645e+00 1.800000000000000044e+00
|
105 |
+
6.500000000000000000e+00 3.000000000000000000e+00 5.799999999999999822e+00 2.200000000000000178e+00
|
106 |
+
7.599999999999999645e+00 3.000000000000000000e+00 6.599999999999999645e+00 2.100000000000000089e+00
|
107 |
+
4.900000000000000355e+00 2.500000000000000000e+00 4.500000000000000000e+00 1.699999999999999956e+00
|
108 |
+
7.299999999999999822e+00 2.899999999999999911e+00 6.299999999999999822e+00 1.800000000000000044e+00
|
109 |
+
6.700000000000000178e+00 2.500000000000000000e+00 5.799999999999999822e+00 1.800000000000000044e+00
|
110 |
+
7.200000000000000178e+00 3.600000000000000089e+00 6.099999999999999645e+00 2.500000000000000000e+00
|
111 |
+
6.500000000000000000e+00 3.200000000000000178e+00 5.099999999999999645e+00 2.000000000000000000e+00
|
112 |
+
6.400000000000000355e+00 2.700000000000000178e+00 5.299999999999999822e+00 1.899999999999999911e+00
|
113 |
+
6.799999999999999822e+00 3.000000000000000000e+00 5.500000000000000000e+00 2.100000000000000089e+00
|
114 |
+
5.700000000000000178e+00 2.500000000000000000e+00 5.000000000000000000e+00 2.000000000000000000e+00
|
115 |
+
5.799999999999999822e+00 2.799999999999999822e+00 5.099999999999999645e+00 2.399999999999999911e+00
|
116 |
+
6.400000000000000355e+00 3.200000000000000178e+00 5.299999999999999822e+00 2.299999999999999822e+00
|
117 |
+
6.500000000000000000e+00 3.000000000000000000e+00 5.500000000000000000e+00 1.800000000000000044e+00
|
118 |
+
7.700000000000000178e+00 3.799999999999999822e+00 6.700000000000000178e+00 2.200000000000000178e+00
|
119 |
+
7.700000000000000178e+00 2.600000000000000089e+00 6.900000000000000355e+00 2.299999999999999822e+00
|
120 |
+
6.000000000000000000e+00 2.200000000000000178e+00 5.000000000000000000e+00 1.500000000000000000e+00
|
121 |
+
6.900000000000000355e+00 3.200000000000000178e+00 5.700000000000000178e+00 2.299999999999999822e+00
|
122 |
+
5.599999999999999645e+00 2.799999999999999822e+00 4.900000000000000355e+00 2.000000000000000000e+00
|
123 |
+
7.700000000000000178e+00 2.799999999999999822e+00 6.700000000000000178e+00 2.000000000000000000e+00
|
124 |
+
6.299999999999999822e+00 2.700000000000000178e+00 4.900000000000000355e+00 1.800000000000000044e+00
|
125 |
+
6.700000000000000178e+00 3.299999999999999822e+00 5.700000000000000178e+00 2.100000000000000089e+00
|
126 |
+
7.200000000000000178e+00 3.200000000000000178e+00 6.000000000000000000e+00 1.800000000000000044e+00
|
127 |
+
6.200000000000000178e+00 2.799999999999999822e+00 4.799999999999999822e+00 1.800000000000000044e+00
|
128 |
+
6.099999999999999645e+00 3.000000000000000000e+00 4.900000000000000355e+00 1.800000000000000044e+00
|
129 |
+
6.400000000000000355e+00 2.799999999999999822e+00 5.599999999999999645e+00 2.100000000000000089e+00
|
130 |
+
7.200000000000000178e+00 3.000000000000000000e+00 5.799999999999999822e+00 1.600000000000000089e+00
|
131 |
+
7.400000000000000355e+00 2.799999999999999822e+00 6.099999999999999645e+00 1.899999999999999911e+00
|
132 |
+
7.900000000000000355e+00 3.799999999999999822e+00 6.400000000000000355e+00 2.000000000000000000e+00
|
133 |
+
6.400000000000000355e+00 2.799999999999999822e+00 5.599999999999999645e+00 2.200000000000000178e+00
|
134 |
+
6.299999999999999822e+00 2.799999999999999822e+00 5.099999999999999645e+00 1.500000000000000000e+00
|
135 |
+
6.099999999999999645e+00 2.600000000000000089e+00 5.599999999999999645e+00 1.399999999999999911e+00
|
136 |
+
7.700000000000000178e+00 3.000000000000000000e+00 6.099999999999999645e+00 2.299999999999999822e+00
|
137 |
+
6.299999999999999822e+00 3.399999999999999911e+00 5.599999999999999645e+00 2.399999999999999911e+00
|
138 |
+
6.400000000000000355e+00 3.100000000000000089e+00 5.500000000000000000e+00 1.800000000000000044e+00
|
139 |
+
6.000000000000000000e+00 3.000000000000000000e+00 4.799999999999999822e+00 1.800000000000000044e+00
|
140 |
+
6.900000000000000355e+00 3.100000000000000089e+00 5.400000000000000355e+00 2.100000000000000089e+00
|
141 |
+
6.700000000000000178e+00 3.100000000000000089e+00 5.599999999999999645e+00 2.399999999999999911e+00
|
142 |
+
6.900000000000000355e+00 3.100000000000000089e+00 5.099999999999999645e+00 2.299999999999999822e+00
|
143 |
+
5.799999999999999822e+00 2.700000000000000178e+00 5.099999999999999645e+00 1.899999999999999911e+00
|
144 |
+
6.799999999999999822e+00 3.200000000000000178e+00 5.900000000000000355e+00 2.299999999999999822e+00
|
145 |
+
6.700000000000000178e+00 3.299999999999999822e+00 5.700000000000000178e+00 2.500000000000000000e+00
|
146 |
+
6.700000000000000178e+00 3.000000000000000000e+00 5.200000000000000178e+00 2.299999999999999822e+00
|
147 |
+
6.299999999999999822e+00 2.500000000000000000e+00 5.000000000000000000e+00 1.899999999999999911e+00
|
148 |
+
6.500000000000000000e+00 3.000000000000000000e+00 5.200000000000000178e+00 2.000000000000000000e+00
|
149 |
+
6.200000000000000178e+00 3.399999999999999911e+00 5.400000000000000355e+00 2.299999999999999822e+00
|
150 |
+
5.900000000000000355e+00 3.000000000000000000e+00 5.099999999999999645e+00 1.800000000000000044e+00
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-boolean-inp.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
2 |
+
1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
3 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
4 |
+
0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
5 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
6 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
7 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
8 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
|
9 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
|
10 |
+
1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
11 |
+
0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
12 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
13 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00
|
14 |
+
1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00
|
15 |
+
0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
16 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00
|
17 |
+
1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00
|
18 |
+
0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
19 |
+
1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
20 |
+
1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-chebyshev-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
8.9084734e-01 9.3573853e-01 9.3507398e-01 9.6040691e-01 9.2918157e-01 9.6617342e-01 9.0430930e-01 9.5753424e-01 8.7106898e-01 9.2169905e-01 9.7401159e-01 8.9013416e-01 9.3956689e-01 9.0041896e-01 9.2588355e-01 9.3849417e-01 8.9713468e-01 9.1481804e-01 9.7500539e-01 9.0012586e-01 9.0962559e-01 8.5860091e-01 8.6981095e-01 8.9995771e-01 8.8070172e-01 9.1456657e-01 8.6711474e-01 9.2593917e-01 8.7560376e-01 8.5193121e-01 9.0898542e-01 8.7765302e-01 8.6555584e-01 8.6093485e-01 9.0447028e-01 8.7614405e-01 9.4803522e-01 8.4998062e-01 7.8398996e-01 8.9538612e-01 8.3902291e-01 9.9039470e-01 9.5480519e-01 8.9152195e-01 9.1623329e-01 7.9094921e-01 9.1777100e-01 9.8972335e-01 9.0429093e-01 8.7646362e-01 9.2136649e-01 9.7178177e-01 8.9610979e-01 9.4710327e-01 9.3612450e-01 9.0241499e-01 7.7992538e-01 8.7262126e-01 9.3325183e-01 8.5796531e-01 9.4267977e-01 6.7224167e-01 7.9568368e-01 8.6411267e-01 9.3311642e-01 9.0160114e-01 9.0698887e-01 8.5833256e-01 9.6902830e-01 9.5072298e-01 8.6808495e-01 9.7879599e-01 8.8060729e-01 8.2818573e-01 8.4366706e-01 8.4506700e-01 9.4532981e-01 9.1792306e-01 7.8917825e-01 9.8337805e-01 8.1751613e-01 9.3037855e-01 9.1618832e-01 8.6568874e-01 8.9751397e-01 8.7923710e-01 8.6814329e-01 9.0330164e-01 8.2426213e-01 9.4644643e-01 8.8431293e-01 8.8497426e-01 9.0633818e-01 9.5537161e-01 8.2167575e-01 8.7771053e-01 9.0681167e-01 8.7626143e-01 8.7463464e-01 9.8033940e-01 9.2920881e-01 9.5108549e-01 9.1287466e-01 8.0052218e-01 9.2409517e-01 8.8252650e-01 8.7873923e-01 9.2989402e-01 9.1985043e-01 9.6172646e-01 8.8223856e-01 9.4477822e-01 8.8310948e-01 9.4461306e-01 9.1875210e-01 9.1233363e-01 9.2124013e-01 9.5460897e-01 8.4640982e-01 9.0882657e-01 9.8169468e-01 9.7828355e-01 8.4150533e-01 8.6888923e-01 9.7138825e-01 8.7988144e-01 9.6720910e-01 8.9450147e-01 9.5331584e-01 8.8871809e-01 8.9736685e-01 8.6258146e-01 9.1331565e-01 9.0968870e-01 9.4833654e-01 9.0536967e-01 9.5099871e-01 8.0251958e-01 9.2526150e-01 9.8971957e-01 9.0340947e-01 9.4955892e-01 9.6838162e-01 8.7534901e-01 9.1178797e-01 9.2649154e-01 9.5260993e-01 9.3178143e-01 9.4943000e-01 8.7816171e-01 9.6506542e-01 8.3422958e-01 9.3443585e-01 9.3220084e-01 8.5706573e-01 8.4666325e-01 9.0474744e-01 9.1080644e-01 9.2406899e-01 8.7901768e-01 9.3265263e-01 9.5992829e-01 9.5696271e-01 9.1932272e-01 8.0937044e-01 9.0904917e-01 8.9516756e-01 9.4797906e-01 8.4159421e-01 9.6773901e-01 9.7099825e-01 9.6941820e-01 9.8174088e-01 9.7569951e-01 9.3655362e-01 8.4130333e-01 9.5994549e-01 8.4235414e-01 9.1429418e-01 9.3418117e-01 8.4600977e-01 8.8166496e-01 8.7594776e-01 8.8571112e-01 9.6308174e-01 9.5315927e-01 8.6997519e-01 8.9383032e-01 9.4686804e-01 9.4399596e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.2420590e+01 3.3246607e+01 3.0526910e+01 3.5166573e+01 3.1868301e+01 3.6025002e+01 3.2513623e+01 3.6557796e+01 3.3752212e+01 3.4422130e+01 3.2526018e+01 3.2581161e+01 3.3743555e+01 3.6960777e+01 3.4225270e+01 3.2965308e+01 3.4591031e+01 3.4204203e+01 3.4678123e+01 3.5728720e+01 3.0830047e+01 3.1550681e+01 3.3304790e+01 3.2676753e+01 3.2742330e+01 3.1684556e+01 3.2830915e+01 3.2956614e+01 2.7365639e+01 3.3207307e+01 3.3420925e+01 3.4357941e+01 2.8280126e+01 3.4523458e+01 3.2705274e+01 3.2455891e+01 3.1636060e+01 3.1594957e+01 3.1805202e+01 3.3886574e+01 3.3438829e+01 3.3330030e+01 3.4168514e+01 3.0637353e+01 4.2149167e+01 3.6340559e+01 2.9315308e+01 3.5778314e+01 3.7693050e+01 3.2598714e+01 3.2990836e+01 3.4967659e+01 3.9748920e+01 3.6745043e+01 2.7117550e+01 3.6014760e+01 2.9367558e+01 3.3845350e+01 3.5477339e+01 3.1513372e+01 3.2517953e+01 2.4755097e+01 3.0229897e+01 3.4799343e+01 3.3371710e+01 2.9600910e+01 3.3275088e+01 3.3567110e+01 3.4527016e+01 3.4942320e+01 3.2359383e+01 3.2607100e+01 3.1467914e+01 2.9032039e+01 3.3122878e+01 2.8496709e+01 2.9908448e+01 2.9962886e+01 3.0345299e+01 3.1737613e+01 2.8551485e+01 3.2610551e+01 3.3082660e+01 3.3719298e+01 3.6434018e+01 3.6589278e+01 3.3889586e+01 3.8036774e+01 3.1483497e+01 3.4196794e+01 3.5154035e+01 3.5488608e+01 3.6143183e+01 3.3473491e+01 3.4686446e+01 2.8687495e+01 3.5725742e+01 3.0188298e+01 3.3084534e+01 3.3538519e+01 3.6226849e+01 2.9052099e+01 3.6032733e+01 3.0811503e+01 3.2616190e+01 3.3888566e+01 3.3074570e+01 2.9683515e+01 3.0600771e+01 3.4345247e+01 3.6983843e+01 3.3692824e+01 3.3762461e+01 3.4024582e+01 3.3698854e+01 3.1238613e+01 3.4978833e+01 3.4991078e+01 3.4577741e+01 3.3749227e+01 3.4982272e+01 3.0487868e+01 3.2317632e+01 3.1125588e+01 3.4413791e+01 3.1881871e+01 3.1373821e+01 3.0416864e+01 3.2066187e+01 3.1128313e+01 3.0240249e+01 3.0125198e+01 3.1343454e+01 3.5479092e+01 3.4450767e+01 3.2953507e+01 3.4456795e+01 3.0136375e+01 3.3462150e+01 2.9894274e+01 3.1367432e+01 3.2839320e+01 3.1440398e+01 2.9400374e+01 3.1106338e+01 3.1242624e+01 3.5537892e+01 3.3056459e+01 2.8610281e+01 3.4296217e+01 3.5819772e+01 3.2503922e+01 3.0963029e+01 3.4762112e+01 3.4796284e+01 2.9645345e+01 3.4468088e+01 2.6975590e+01 3.3738555e+01 2.8825009e+01 3.2663999e+01 3.2547878e+01 3.2308091e+01 3.2489966e+01 3.0868597e+01 3.2974220e+01 3.0866111e+01 3.8197342e+01 3.0609568e+01 3.5478978e+01 2.9249184e+01 3.6185622e+01 3.1948258e+01 3.2649719e+01 3.3305650e+01 3.4643955e+01 3.6566241e+01 3.4968484e+01 3.2632218e+01 3.6741383e+01 3.5700008e+01 3.1962468e+01 3.1410623e+01 3.0412061e+01 3.3749077e+01 3.5649661e+01 3.7649263e+01 3.2832574e+01 3.1783914e+01 2.8264292e+01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-correlation-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
9.2507465e-01 9.6528566e-01 8.7255441e-01 1.1287379e+00 8.7318727e-01 1.0767102e+00 9.1419676e-01 1.1503304e+00 9.8074509e-01 1.0135025e+00 1.0495025e+00 9.4794536e-01 9.6829273e-01 1.1345767e+00 1.1048008e+00 9.2407796e-01 1.0228634e+00 9.3853195e-01 9.9377619e-01 1.0407662e+00 9.5048989e-01 9.0465688e-01 9.8056930e-01 8.9777156e-01 9.6357127e-01 9.3864452e-01 9.9754613e-01 9.7271356e-01 8.4383151e-01 9.6981983e-01 9.7510267e-01 1.0112663e+00 7.8730400e-01 1.0299498e+00 9.9307979e-01 9.0239520e-01 8.5428231e-01 8.8972742e-01 8.5933162e-01 9.6625934e-01 9.4175449e-01 9.9120729e-01 1.0503963e+00 8.8223053e-01 1.3261434e+00 1.1063209e+00 8.4058398e-01 1.0844267e+00 1.1153093e+00 1.0092643e+00 8.9585237e-01 1.0599818e+00 1.2321707e+00 1.1359624e+00 8.3503556e-01 1.1792243e+00 7.9159781e-01 1.0830419e+00 1.2181870e+00 9.9888500e-01 1.0227144e+00 6.8557277e-01 9.6836193e-01 1.1061227e+00 1.0883453e+00 9.5681974e-01 9.9436299e-01 1.0304323e+00 1.1273949e+00 1.0735563e+00 1.0582583e+00 9.6040272e-01 1.0032137e+00 8.4900547e-01 1.1035351e+00 8.7867480e-01 9.6433176e-01 9.1850122e-01 8.9337435e-01 1.0449390e+00 8.9639384e-01 9.6704971e-01 1.0084258e+00 1.0528587e+00 1.1764481e+00 1.0913280e+00 1.0136672e+00 1.2737156e+00 9.5130359e-01 1.0367909e+00 1.1983402e+00 1.1319901e+00 1.1117462e+00 1.0343695e+00 1.0838628e+00 7.5266057e-01 1.0763316e+00 8.8067924e-01 9.6734383e-01 9.8800551e-01 1.2265742e+00 7.8833055e-01 1.0338670e+00 8.6666625e-01 9.9039950e-01 9.7142684e-01 9.3138616e-01 8.5849977e-01 8.5486301e-01 1.0516028e+00 1.1105313e+00 9.5943505e-01 9.8845171e-01 1.0566288e+00 9.9712198e-01 9.5545756e-01 1.1817974e+00 9.9128482e-01 1.0117892e+00 1.0979115e+00 1.0493943e+00 9.1318848e-01 9.3157311e-01 8.7073304e-01 1.2459441e+00 9.3412689e-01 1.0482297e+00 9.4224032e-01 9.5134153e-01 9.0857493e-01 9.7264161e-01 8.2900820e-01 9.3140549e-01 1.1330242e+00 1.0333002e+00 1.0117861e+00 1.2053255e+00 8.5291396e-01 1.0148928e+00 8.6641379e-01 9.7080819e-01 9.5457159e-01 9.5207457e-01 9.3539674e-01 9.0769069e-01 9.5322590e-01 1.1181803e+00 9.9765614e-01 7.5370610e-01 1.0807114e+00 1.0804601e+00 9.0214124e-01 8.7101998e-01 1.0167435e+00 1.2045936e+00 8.7300539e-01 1.1054300e+00 7.9145574e-01 1.0279340e+00 8.7623462e-01 1.0034756e+00 1.0386933e+00 9.3910970e-01 1.0028455e+00 9.9868824e-01 9.8752945e-01 9.8319327e-01 1.3110209e+00 8.6180633e-01 1.0993856e+00 8.5912563e-01 1.1303979e+00 9.8690459e-01 9.6910090e-01 9.1456819e-01 1.1525339e+00 1.1064552e+00 1.1062255e+00 9.7226683e-01 1.1091447e+00 1.1072238e+00 9.6544444e-01 9.6681036e-01 9.3247685e-01 9.6854634e-01 1.1035119e+00 1.1317148e+00 9.5557793e-01 9.8908485e-01 7.4873648e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cosine-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-cosine-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
2.5695885e-01 2.6882042e-01 2.3470353e-01 2.9299329e-01 2.2742702e-01 3.1253572e-01 2.4986352e-01 3.0770122e-01 2.5191977e-01 2.7931567e-01 2.8133743e-01 2.6316239e-01 2.6067201e-01 3.2982339e-01 2.8993002e-01 2.5506356e-01 2.8728051e-01 2.4952121e-01 2.8613379e-01 2.6894157e-01 2.3606353e-01 2.1670935e-01 2.3470242e-01 2.4294172e-01 2.4376454e-01 2.3228195e-01 2.3554918e-01 2.4851241e-01 2.0917546e-01 2.4971488e-01 2.4264224e-01 2.7405461e-01 1.9086415e-01 2.6346574e-01 2.5908801e-01 2.2138495e-01 2.2910721e-01 2.2169919e-01 2.0660065e-01 2.3207102e-01 2.5554688e-01 2.5153751e-01 2.6073682e-01 2.0919640e-01 3.3984433e-01 2.7503792e-01 2.1709889e-01 2.7068095e-01 3.0307041e-01 2.4529612e-01 2.2987015e-01 2.7736967e-01 3.0310708e-01 3.0544316e-01 1.9205388e-01 2.7098021e-01 2.0722466e-01 2.6387343e-01 2.8998308e-01 2.2633010e-01 2.5177075e-01 1.6347011e-01 2.4036389e-01 2.6485871e-01 2.8491965e-01 2.2273619e-01 2.4511873e-01 2.5930533e-01 2.6589995e-01 2.7797191e-01 2.3357373e-01 2.4279909e-01 2.3544532e-01 1.9447286e-01 2.3993534e-01 2.0856243e-01 2.2125251e-01 2.1988206e-01 2.0590152e-01 2.6441952e-01 2.0052739e-01 2.2978496e-01 2.4483670e-01 2.3879510e-01 2.9398425e-01 2.7541852e-01 2.3777469e-01 2.9151131e-01 2.0672752e-01 2.4584031e-01 2.7475025e-01 2.7064343e-01 2.5603684e-01 2.6165327e-01 2.4233155e-01 1.7892657e-01 2.6111203e-01 1.9965682e-01 2.4201634e-01 2.6281353e-01 3.1928221e-01 1.9731963e-01 2.7752862e-01 2.2633080e-01 2.6783167e-01 2.5447186e-01 2.6424243e-01 2.1960672e-01 2.2984242e-01 2.8788736e-01 2.8681630e-01 2.6949787e-01 2.3993685e-01 2.4440073e-01 2.5010397e-01 2.3230769e-01 2.9879682e-01 2.4200592e-01 2.6957748e-01 2.6073240e-01 2.6355347e-01 2.3403674e-01 2.2411413e-01 2.2956729e-01 2.8105976e-01 2.2913304e-01 2.4898608e-01 2.3304000e-01 2.2692988e-01 2.3728251e-01 2.2552243e-01 2.0364084e-01 2.3359511e-01 2.6619167e-01 2.6666588e-01 2.3666880e-01 2.7239113e-01 2.0146697e-01 2.3045559e-01 2.1695523e-01 2.1387991e-01 2.2366404e-01 2.2809635e-01 2.0901297e-01 2.2441100e-01 2.3418882e-01 2.8552218e-01 2.4609015e-01 2.0282492e-01 2.5940295e-01 2.7407006e-01 2.3344890e-01 2.1179142e-01 2.7047821e-01 2.9832768e-01 2.0859082e-01 2.8881331e-01 1.8384598e-01 2.5286491e-01 2.2012615e-01 2.3615775e-01 2.6845565e-01 2.3356355e-01 2.7164193e-01 2.4179380e-01 2.5247973e-01 2.5637548e-01 3.2126483e-01 2.3100774e-01 2.8832546e-01 2.0043257e-01 2.7918333e-01 2.4884522e-01 2.2904723e-01 2.3738940e-01 2.9461278e-01 2.9782005e-01 3.0332073e-01 2.5175971e-01 3.1203784e-01 2.6611535e-01 2.3713507e-01 2.2203585e-01 2.3602325e-01 2.5093670e-01 2.6860434e-01 3.0137874e-01 2.3759606e-01 2.6840346e-01 1.9200556e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-double-inp.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
8.278938049410748956e-01 9.035293984476246987e-01 1.862188994679486731e-01 8.921151312310462433e-01 2.061859119379583216e-02 3.440636727385729676e-01 1.533779912830328662e-01 5.701372300009802663e-01 5.510020730211558915e-01 1.792362258426003496e-01 8.086175120876580857e-01 6.115487184317183189e-01 1.233471787164852618e-02 1.441643531871039663e-03 4.044309209045688913e-01 3.561398959499905148e-01 1.281985712929750720e-01 8.663300833847481508e-01 8.696027786291581352e-01 3.611727370363766454e-01 5.283537658772616830e-01 1.440241088090119526e-01 3.112457227138950566e-01 6.031280796897889873e-01 9.230324792742518047e-01 2.332121881136874908e-01 3.192652267403439659e-02 3.466206294995559656e-01 2.988687728046366399e-01 5.116749542048093513e-02 2.584975830914494344e-01 4.302023478042227289e-01 8.003972751713522849e-01 9.364931911368097328e-01 9.737098649964673891e-01 4.718038453972229762e-01 4.526591686607864817e-01 1.056485678520797666e-01 5.883019714285405710e-01 3.846092237676981274e-01 6.461500053435473845e-01 1.013239729848824933e-01 1.216151561651189761e-01 5.159668929484659827e-01 8.452074473510227115e-01 9.885170962247968873e-01 7.623883073490128615e-01 2.291163243615434997e-02 5.775530980802381364e-01 7.820699896828091635e-01 8.239186345842965942e-01 3.391800105260227571e-01 9.546318451614538292e-01 3.789677917867695367e-01 4.526533399649290690e-02 8.366786473238587707e-01 3.082636811049858094e-01 1.173936820793450853e-01 7.631994969169442200e-02 2.997416650722183329e-01 5.795208655160232203e-01 3.942350892542011431e-01 1.175126383297261379e-01 4.928232513950027149e-01 9.421293996225950096e-01 8.365391053841342295e-02 6.868059693571844093e-01 3.589527962429440722e-01 7.592939427166059962e-01 5.623849466131448649e-01 2.110746828032050715e-01 9.824683704668600859e-01 2.661230142246236996e-01 6.162272315007123469e-01 5.023254536607497656e-01 5.202854476669782624e-02 5.835090668842095596e-01 7.864642118889143552e-01 2.504012386867506823e-01 6.728308641135989365e-01 4.610793534576096420e-01 4.820508770515909980e-01 9.720403251022265989e-01 3.100069285263498120e-01 7.681017126461753275e-01 7.956539306007082146e-02 2.593389637887737464e-01 1.137852590403054531e-01 3.885303073284454012e-01 8.599094660075957686e-01 5.215167875918280682e-02 1.620908248572288102e-01 1.859236090457663249e-01 6.247716512610480555e-01 3.415128495520775020e-01 7.034903368378029320e-01 6.037564640019568163e-01 2.338969434423310290e-01 1.002104885609900187e-02 7.866058403969036217e-01
|
2 |
+
8.033694116033356369e-01 8.653264545544031572e-01 7.468340410754038539e-01 6.362430919910603278e-01 5.120006306625468628e-02 9.503348372633585450e-01 4.697732609626817935e-01 4.221305288459429317e-01 3.153452119838391354e-01 2.991014843442657556e-01 1.190667967280257811e-01 3.486567714509342109e-01 8.289493649885054660e-01 8.454811050800014049e-01 9.149673018211901265e-01 7.708707837193897738e-01 2.640157732122547785e-01 2.107897022189605396e-01 4.207633055054439408e-01 6.719500284654699174e-01 1.458031684893063007e-01 1.800412735886125493e-02 8.402733435220011149e-02 4.206760156883160295e-02 1.376933515041314227e-01 1.716717341022133692e-01 1.788220727652158892e-01 8.224310433402118869e-01 7.729093666867475898e-01 2.064223621025984556e-01 9.592092036227207741e-01 8.312490243754996344e-01 6.673289360369902834e-01 4.632847903690773261e-02 7.643954098358983762e-01 9.359341525615098023e-01 1.914966319163026176e-01 4.536590469402868031e-01 8.640836016538007147e-01 3.941529178175462444e-02 5.602101995205478469e-01 9.263806161941660067e-01 1.555995325944817820e-01 6.172208102950116348e-01 6.335576752812099866e-01 9.766975460368043649e-02 4.475795689539874278e-02 3.248842796104995934e-01 5.700377122149502540e-01 9.066962967256807504e-01 5.458460621505676347e-01 6.833401285581487405e-01 2.887244409544044155e-01 1.316338647016834784e-01 2.325673305245992140e-01 4.150121963188406760e-01 3.834845466366055833e-01 8.149365773968725302e-01 1.867003849450201702e-01 3.170322173543018707e-01 6.832093662682684476e-01 1.729728518929105618e-01 9.236557359702636250e-01 9.152941252150086360e-01 7.224879983096620384e-01 8.557920626598064517e-01 5.344883059251644974e-01 4.876873274449112783e-01 8.308277804506420949e-01 3.916624489322212410e-01 3.459695122273966916e-01 4.033512499027409604e-01 6.555726444913008155e-01 7.138452409380238173e-01 1.683937314599968094e-01 1.769382143486440961e-01 7.588683655178136700e-01 3.750589892880819010e-01 7.525176245126207197e-01 6.083961152538303052e-01 1.145972309907993258e-01 6.239614485809552580e-01 1.307655482065895880e-01 8.530458750670916190e-01 4.801602070124768584e-01 8.168122189863546989e-02 3.793139622744635675e-01 1.496986997776840189e-01 7.129023878302899186e-01 6.830979237438047358e-01 7.635375943876505644e-01 1.824004963251233402e-01 5.764695848992339444e-01 8.865113248731604223e-01 5.784337085544002388e-01 9.700026628755119562e-01 7.318207347905059112e-01 3.851401393936705331e-01 1.774291851193399161e-01 9.763423229242296220e-01
|
3 |
+
9.287178470949695175e-01 1.748282433617460718e-01 9.238531711586964734e-01 8.291274445125006443e-01 9.513259272578692416e-01 7.486316801165745494e-01 6.257378457524477300e-01 2.062711693536473101e-01 3.970721244184766130e-01 2.738325225026445597e-01 8.735038948299954642e-01 5.415282140033768066e-01 5.176317904298315398e-01 5.347036264518250093e-01 7.482056965410627258e-01 4.140672582824351800e-01 8.709067272363142376e-01 9.499605569181273079e-01 5.380266748336398619e-01 4.369252161707162241e-01 8.235722216228258397e-03 4.308187193646527691e-01 6.030581482859224129e-01 7.316831195156517920e-01 5.540499846834291420e-01 2.044203040111662872e-01 8.645251782981867583e-01 1.816095717570278545e-01 9.639119168018674966e-01 3.572031072322333634e-01 5.580226816834680248e-01 5.586629875016585478e-01 7.213854320902782780e-01 8.513998260042524580e-01 6.308764347277173723e-02 4.299855362100638567e-01 8.789303907444128150e-01 9.178850359236285783e-01 2.275205845091231582e-01 1.899395443939643213e-01 7.103070862773533944e-01 9.450015289553428399e-01 1.691856364522159595e-01 7.368719616877857925e-01 9.600189536623833231e-01 5.128846522932454244e-01 6.209162727118655578e-02 7.992250598838029907e-01 9.141050280518014937e-01 1.471297785256820978e-01 7.466162372930541524e-01 4.656107650642931084e-01 6.399324135161845728e-01 2.023617619481610230e-01 1.019104648900100996e-01 4.390693688536728700e-02 9.822620353006089600e-01 2.881951852926285529e-01 6.191575015960482098e-02 8.989580763251467932e-01 4.635958631890454429e-01 1.781973138114967270e-02 7.906911683818984571e-02 6.525270776225711167e-02 3.620583622807886925e-01 2.651673718940715796e-01 5.829372395929610651e-01 2.118159824373908595e-01 5.900287159143694504e-01 9.405929925178391215e-01 9.262415619063500971e-01 5.639581506302312475e-01 4.529556154689695635e-02 2.873819210518682166e-01 5.718545934306838996e-01 9.877670791317306742e-01 4.120364488714320927e-01 9.896078045634184583e-01 3.796586997026456523e-01 1.178183652203194098e-01 6.641068305236120795e-01 4.045960610587706618e-03 2.262690437428437340e-01 7.839938005832693957e-01 7.695391333937223743e-01 3.713918392552509884e-01 4.245533341514018399e-01 1.475072494020331915e-01 6.011975181419888514e-01 5.158174017998343741e-01 1.788706151398071764e-01 8.880707130134481986e-01 6.463351030474082659e-01 6.499920635615744624e-01 8.570273676455353318e-01 6.055019270899113515e-01 2.123561211054603159e-02 2.027688787664126968e-01 1.930834215328548487e-01 5.131906052747271518e-01
|
4 |
+
2.599990881903107010e-01 6.767857524909899336e-01 7.188217446352963558e-01 3.037178903357997672e-01 4.252381412838680541e-01 4.070924411439535984e-02 8.426710493038247485e-02 8.301517457289483426e-01 8.254603255702420705e-01 7.258533909453509514e-01 9.958706809470796451e-01 1.323408451651194584e-01 8.523995455245143571e-01 2.572405385832454705e-02 4.715363690065482727e-01 7.920130365690022378e-01 7.613745641534582775e-01 5.108305991695683002e-01 7.908714335912382376e-01 4.641131983754837043e-01 3.112627109831845873e-01 4.218013908715474436e-01 3.291577909008427394e-01 2.538715054071232213e-01 1.362470842487485401e-01 2.716429790290709745e-01 1.485325814161112534e-01 4.514539027544387517e-01 6.900835128673067365e-01 7.793407072946112457e-02 5.938024345270752624e-01 1.497853829906865553e-01 5.399567982652856424e-01 1.419209916759478496e-03 7.719776132867679497e-01 3.130795105576239523e-01 6.670071611167494030e-01 8.900596881158256979e-01 8.011158503301568645e-01 7.089295605187424520e-01 4.671116382997058114e-01 6.682965170673403899e-01 6.524835265739736823e-02 5.454288420771494783e-01 7.751910790556310049e-01 8.192595541387335256e-01 3.098855848167891835e-01 3.689971355659119601e-01 8.666507475054133769e-01 2.749042684253171220e-01 3.566565602478318775e-01 4.838173174723044978e-01 1.032975933616413489e-01 5.063065339610417492e-02 5.791168455729079900e-01 3.573337411289496668e-01 6.714098909652352898e-01 2.917057662433912846e-01 2.654964332620638467e-01 7.171804039048814694e-01 3.314488637898249657e-01 5.230399837442840649e-01 6.866534136026025692e-02 1.252966394621071178e-01 5.349397882659551184e-01 2.841423847455760709e-01 4.158473635710734362e-01 7.197062989831272128e-01 5.123869045047864113e-01 8.675622821594339840e-01 8.097441845042540054e-01 7.317178252133832439e-01 3.300847596465853462e-01 5.922311859141077273e-01 8.852619511417836318e-02 2.673412917259408994e-01 6.878259052441990651e-01 3.223000927116328462e-01 8.859387123976615319e-01 5.722722388300067742e-01 8.254877606669521750e-01 5.705299682290687624e-01 7.046478734972855262e-01 1.316324413616759559e-01 3.056358395675535800e-01 2.396516834600909140e-01 2.041201422493257311e-01 1.610755140653103989e-01 1.617012564641111538e-01 4.449920510036902144e-01 2.731012972755201274e-01 7.826874666257994662e-01 5.193612375350010746e-01 8.688804522977213729e-01 3.742157602758655610e-02 6.649628920608219307e-01 5.978149424619171315e-01 5.345645500553952711e-01 9.443202650415919441e-01 6.105837075491723498e-01
|
5 |
+
6.387761328141735584e-01 4.210087412162694109e-01 3.777306694964789324e-01 3.576349403292201634e-01 7.272699618880260619e-01 9.173392803607671731e-02 1.212535698300880593e-01 3.871229381194544183e-01 7.735150198351389284e-01 4.687200483013695962e-01 5.161778571874678923e-01 9.839646447226980674e-01 8.626932748911960713e-01 9.618485576577924245e-01 2.997996427525421170e-01 3.955404657388794654e-01 8.480126027102616870e-01 8.194992325050480808e-01 2.800213436873294492e-01 7.188391466620779324e-01 2.289766105875049584e-01 3.838547514028287644e-01 1.363553401061209369e-01 2.131328253542326134e-01 2.666779468144075960e-02 3.252883844200405994e-01 4.207860197469600605e-01 2.991365385037647595e-01 9.180779845534067229e-01 8.787338732192649937e-01 5.404510999105649471e-01 1.735493827761729335e-01 7.405224640747264386e-01 3.927355563629583157e-01 3.957109873399460298e-01 1.313029813325972128e-01 6.434498219738993274e-01 7.162213694578050127e-01 6.454998257494671821e-01 3.808124530008022424e-01 2.027201015737234435e-01 6.667632842770417900e-01 1.609491052365198405e-01 1.192413785409307536e-02 4.546773323526854815e-01 7.733541911050207940e-01 3.902525737195561284e-01 4.006023779897505133e-01 5.156517815815246930e-01 6.135685498584592112e-01 7.062153114980724844e-01 5.505858882117883324e-01 3.541308807182554919e-01 5.237151122342533771e-01 5.230649229131387745e-01 1.973541027697351957e-01 7.940327858595511712e-01 9.998588700623055603e-01 3.878271015153827994e-01 4.455006584967207139e-01 8.376414508056347907e-01 3.310833863524501597e-01 8.020469097392601832e-01 1.890327633084128989e-01 3.830289472395409511e-01 8.605040171046141051e-02 9.978185524023941433e-01 8.333890591892906263e-01 4.509013468741837061e-01 6.355778557686052599e-01 1.422515991097305088e-01 9.549891485963732940e-01 7.535776302868563148e-01 9.306005301880662106e-01 2.444330347211679522e-01 5.828218427569508142e-01 1.261938242968304591e-01 2.829188731405173352e-01 8.100246952078660190e-01 2.032739130996042975e-01 3.997268448390065565e-01 3.882777703107541667e-01 1.102505652624736765e-01 5.826634725328041498e-01 6.508734477956333864e-01 1.777287661702166011e-01 4.857051012052149286e-02 6.850537712379254351e-01 5.012281307761055071e-01 3.329154880061502286e-01 5.006261767216675374e-01 4.542081454976160115e-01 6.777801995399822532e-01 4.271303586474960445e-01 7.820470659692947413e-01 5.143462618485082904e-01 4.071273891563575997e-02 8.503383643856671226e-01 6.877485768345151795e-01 6.498843855014626580e-01
|
6 |
+
5.539512747016193117e-01 6.329206647391879548e-01 2.798533500321682688e-01 4.825977295850051307e-01 7.625297023172977751e-01 9.081309101427640362e-01 4.124792086535029600e-01 3.647019658319609059e-01 7.529595202332928228e-02 3.072404010876803593e-01 7.890673660964639957e-01 4.079781478915127657e-01 1.440519120695739064e-01 2.538968953804546791e-01 1.595028243568367143e-01 9.066545851872198636e-02 6.367601114674349416e-01 7.622263643880089479e-02 3.015728236404162654e-01 2.424070469873378375e-01 5.711440390241000475e-01 5.717001375511508998e-01 2.237853674032181939e-01 7.112101625753678436e-01 4.321054197012103026e-01 2.505322169010260058e-02 5.877307077139551916e-01 4.415771174397812304e-01 3.766022855145171322e-01 9.803490652619811785e-01 1.229258314111529860e-01 8.108351868714478439e-01 8.558595456964329662e-01 2.168217533833206589e-01 2.034022719386595623e-01 8.687457137579783772e-01 9.013327195854559104e-01 8.156766512673154779e-01 2.717576187546973943e-01 1.756417893371479133e-01 7.555856977566548505e-01 6.708809351312817748e-01 8.998789237886926085e-01 1.936367585946979775e-01 7.949724635465026390e-01 3.164799312763589834e-01 5.493048513173155456e-01 1.608917269168268493e-01 3.048667492191803330e-01 5.599401537727016764e-01 5.779501360842279611e-01 1.296714605309662316e-01 9.160752328055997706e-01 8.058674476110374574e-01 4.385508937505578908e-01 9.212419718012100356e-01 2.249887451242467140e-01 6.283927745352599903e-01 3.778992451536005159e-01 3.571958698867505611e-03 7.276526470528231760e-01 9.051678673805297892e-01 8.465837072484881931e-01 4.548317505393462135e-02 3.189318261926020748e-01 4.446388607398673587e-01 4.292356336344156365e-01 4.203980977718795309e-01 4.698059253071955599e-01 6.151991200848159203e-01 8.479986139404802614e-01 9.870993262459623052e-01 3.164206525899861955e-01 6.464672171639846976e-01 8.508781429592480183e-01 4.733667503354813677e-01 8.076014176740163863e-01 6.671443255679101458e-01 6.639213267047979761e-01 3.681688930741919830e-01 4.679870252651611162e-01 1.790041740686979521e-01 8.446070273663058847e-01 3.350737544979878191e-01 6.600272349677447359e-01 4.356083218487936115e-01 7.995134167346013010e-01 9.083660261041469619e-01 9.743975306734570241e-01 8.144839650654719376e-01 6.865011984586443239e-01 1.709747281999153268e-01 8.534933687161740945e-01 9.494753729726415070e-01 8.140124992294850426e-01 8.936241255316055287e-01 9.087976860818796077e-01 9.030687493451383663e-02 4.025785149840914734e-01 9.592005611533803711e-01
|
7 |
+
5.714058727476275523e-01 7.913573761505965365e-02 9.301773447377043036e-01 4.302822433307075256e-01 4.618892554175407783e-01 1.882471300213742760e-01 6.231472878215863487e-01 2.350437450940777717e-01 8.483410480771292894e-01 8.580803842040533036e-01 4.246398783388435350e-01 5.667321565946502604e-01 7.247417018955526480e-02 5.373984417482219333e-01 8.794242091541510931e-01 9.699025554453030162e-01 8.254197752548814160e-01 7.739723972867470492e-01 6.365819416181199841e-01 3.451230687021222820e-02 1.829102490094791644e-02 9.179618383026147965e-01 4.481667270072077214e-01 4.771270250445739380e-01 1.588469404953456454e-01 3.766332499200618633e-01 5.057026248713025751e-02 9.125900914275182352e-01 8.438133644246305076e-01 3.282972411719701222e-01 6.042003956122835584e-01 7.423456085393266290e-01 1.389012737541106546e-02 3.674754266702850991e-02 2.126646727703802586e-01 3.085666164246750887e-01 4.303440338750976757e-01 1.749037978865556342e-01 2.177699993322510519e-01 6.675614739991906355e-01 1.926533336347433512e-01 8.032010572660308600e-01 4.611412981769049679e-01 9.907201268457492827e-01 8.973785930837320235e-01 6.286342392657409128e-01 8.111266245859546364e-01 1.154230969025437092e-01 8.382880466301794176e-01 1.053753927827069115e-01 9.921712862234919328e-01 9.041662667920956631e-01 3.626267376021269362e-01 2.262225368932846425e-02 8.669003741626111204e-01 7.597054897704164089e-01 4.700318514995387442e-01 4.338185014241978665e-01 1.205425463362067573e-01 2.413879270602589111e-01 5.483334840461459025e-01 2.042653841254596925e-01 5.452588940366013270e-01 3.164646091706100339e-01 1.878958248945691301e-01 2.188622304737641855e-01 2.970982599823450698e-01 5.952148400199362976e-01 9.614251220149501176e-01 5.446813400697393392e-01 5.900748097930779146e-01 2.653062526715309621e-01 5.459933097767216692e-01 3.174185404661935550e-01 1.412133354129242457e-01 1.487441669790685594e-01 3.953776242211952674e-01 5.274261039692862418e-01 1.756132307607755072e-01 4.481942852746899630e-01 6.390660088765629521e-01 2.860380430081067571e-01 5.866902519902850166e-03 3.026687645174785946e-02 1.952533570196290924e-01 2.154769096186736066e-01 8.920573593276575064e-01 5.644513191915436767e-01 5.551464696654353492e-01 4.378199413349500579e-01 8.685737643974280608e-01 7.493934764293597173e-02 9.556749726352036234e-01 6.386433482536227890e-01 8.714694524097754691e-02 1.722786161701279628e-01 6.526867532768643176e-01 8.950304705281527662e-01 6.158198776753203152e-01 9.587176904005377809e-01
|
8 |
+
7.705718397401561948e-01 3.165816092999733655e-01 4.334200859975760878e-01 8.639807015515663657e-01 5.576514209532534849e-03 2.456745447057938625e-01 1.664686313299922338e-01 9.637084729617834133e-01 1.083448720752323569e-01 1.865218070380464388e-01 3.730358890475884426e-01 5.015351872138350542e-01 7.420710795841709562e-01 4.919420674769692248e-01 3.426558201886464872e-02 8.669984854934246199e-01 2.204243734202966376e-01 4.109792246853891662e-01 4.361732572946559472e-01 6.819306998053020763e-02 9.986304248057148447e-01 4.119289455392274313e-01 8.533050041845835487e-01 3.416914861912183632e-01 6.522191951039880697e-01 4.162803668786793088e-01 9.051674379917418189e-02 4.552378661306888397e-02 2.122677193466918633e-01 7.461518531655018105e-01 4.654688019259497489e-01 7.877564083548750373e-01 4.518328005682387127e-01 7.173857464237374248e-01 6.940056370290903498e-02 2.804574410412373764e-01 6.095681113112718652e-01 3.680596478602831123e-01 1.814569150719304025e-01 6.505055517979729807e-01 2.759585245701871026e-01 1.429501104786028431e-01 7.813891153083207808e-02 8.925314279991185540e-01 6.692056941902108091e-01 1.915141341107173822e-01 5.750233129581091562e-01 2.051961006251528108e-01 3.849013692629975614e-01 9.503788222043518807e-01 7.690419386411734282e-01 9.978147530014782607e-01 1.719584162437415298e-01 4.890758882401113894e-01 7.195660736040896399e-01 2.485818040997200828e-01 9.706486601870933928e-01 5.182604282071262558e-01 8.082072245463804983e-01 4.889961284821118248e-01 8.042893959057633158e-01 3.200685313413229593e-01 8.983245016887355661e-01 2.811495336955205371e-01 3.986095833814048417e-01 8.607229214132059436e-01 4.827620119717191960e-01 6.715610252037491623e-01 9.330824374137768329e-01 7.537710530085762750e-01 9.840804224010484269e-01 2.319352541177217564e-01 9.569114943157627229e-01 5.821928104654411351e-01 6.700479524814679788e-01 5.663434680086896211e-01 8.851091082101365526e-01 6.800562815862243315e-01 3.578475213752868589e-01 2.900164669281133367e-01 8.379170683569914235e-02 9.929972839740475177e-02 5.946248553621906741e-01 1.991332889320840405e-01 8.115065723822508792e-01 2.023388190440008616e-01 4.056545651129230823e-01 2.966825350250481552e-01 7.457176343507545546e-01 9.856015771246517954e-01 2.264338016147812160e-01 8.366528670045663141e-01 6.116829813603242849e-01 2.605933184296719274e-01 5.765962146558850643e-01 5.064075092266390188e-01 5.499615769589756287e-01 9.240234698632640020e-01 7.169900155229913530e-02 3.544181364560751168e-01
|
9 |
+
8.154844535553099627e-01 4.797965609394789777e-01 7.476703385713100447e-01 9.086708404761600910e-01 3.191752505450355937e-01 7.611128630021511965e-01 6.246790343299296611e-01 1.942001426217137006e-01 2.789860414631386565e-01 3.236359785042408621e-02 3.178191288741717413e-01 8.372264298357038337e-01 8.872692914664047636e-01 9.589758852077276963e-01 3.123722260380168425e-01 8.980164015338999439e-01 7.260784140459818348e-01 6.567013512265649222e-01 1.028743505926521529e-01 6.821705410750319443e-01 6.889838995316139858e-01 5.587525493094736007e-02 6.921487028366646310e-01 3.616312929861494885e-01 1.673758008792780583e-01 6.626504595920326146e-01 9.125680913222075086e-01 1.424077784972291871e-01 6.508496429060767197e-01 6.615417385775157477e-01 9.654167310675311198e-01 5.536662974550183858e-01 7.092622144968085962e-03 6.694595400455760625e-01 1.828533619119211417e-01 3.421514408394116247e-01 1.242580151818144518e-01 9.888774797458224075e-01 9.777955172739735135e-01 4.271370765628749178e-01 1.211608384809655936e-01 1.580132417172936954e-01 3.242705395708289640e-01 3.268994391754735940e-01 5.213767653645562383e-03 4.475169480357120699e-01 9.593245219293577986e-01 6.994304536782350867e-01 7.063863152769014331e-01 8.381620829497931080e-01 2.760441799736219615e-01 3.755200946645842475e-01 3.627729621737311172e-01 9.518310606719182498e-01 3.577273025276901386e-01 3.991159901003488164e-01 4.187060513068554535e-01 7.422605403637314581e-01 6.697944269780702342e-01 6.020599837037767799e-01 1.571185850817550245e-01 7.519860911185742847e-01 6.635775704496444938e-01 9.487848173531471252e-01 7.900030232338028924e-01 4.143783957270819052e-01 5.618429740858444932e-01 3.737804619062014000e-01 6.179941187802344693e-01 6.553638605616040058e-01 1.009709416658691739e-01 4.935037098582963910e-01 5.485489972455533936e-01 1.024147956480448984e-01 1.195764707555347917e-01 4.910516327810896531e-01 3.551185778630389089e-01 3.857601645798814927e-01 2.074975219600547760e-01 2.084038664460790002e-01 5.268616653491025037e-01 6.948014877618717833e-01 6.179744044618615817e-01 7.063658085955483168e-01 7.925757227686872630e-01 6.199016959584816577e-01 1.163676037434490107e-01 7.425752264755586252e-01 5.403115665133301215e-01 2.546191951391015840e-01 6.961300925345208501e-01 4.003013072125547467e-01 5.906120962720950995e-02 5.879915846330325824e-01 1.213602408288709800e-01 3.801780679842765576e-01 1.731477742402802722e-01 4.624568816669496485e-01 3.304453744619206823e-01 8.810445876116090869e-02
|
10 |
+
5.140190515373614932e-01 1.419225260054487459e-01 7.777845802285945354e-01 3.327562899409282071e-01 8.916875699762913943e-01 7.212852862736146564e-01 5.727327199433507321e-01 5.897820225918504189e-01 7.318614954542906892e-01 7.393985144455500480e-01 4.531340740296823100e-01 9.903061584426188224e-01 4.213350938331624773e-01 4.542342471963995987e-01 9.788786426453045530e-01 1.881707000343846303e-02 8.005433413647761176e-01 1.523502822273363755e-01 5.630164732287495921e-01 5.946603842470724599e-01 1.225547698678740582e-01 1.531136594724622491e-01 8.157973612638946825e-02 2.752046015644330490e-01 6.809045821946161370e-01 6.455289724528190387e-01 3.830356726830793646e-01 4.446144649678575034e-01 4.969038423960672191e-01 5.497873820641221432e-01 9.471879627821714331e-01 5.933046675329255448e-01 4.099233758501530378e-02 5.790409810134594659e-01 9.546095885251496549e-01 2.608616052375664074e-01 6.910160339170060562e-01 1.293709850476291168e-01 6.407264616302255078e-03 6.186037089828009261e-01 5.537861302543241049e-01 3.527421038298221845e-01 8.033232052121624944e-01 8.128114152830284711e-01 8.319982582278713235e-01 5.939566376046836460e-01 2.291090283499520597e-01 5.438101817725821130e-01 6.881146379117278888e-01 2.421968586304659166e-01 5.874047918543783275e-01 6.210102709484541794e-01 7.041387566450251212e-01 6.959223476278774134e-01 9.133877300988062498e-01 9.230647706207778525e-01 6.856884219815310155e-01 6.997988808693775820e-01 6.177944932528769417e-01 5.512902545683161515e-01 5.818280341729102911e-01 6.538267999985679646e-01 6.946673485935980219e-01 4.817938258357623571e-02 9.352008817207906333e-01 4.774162142215661042e-01 5.768063588692976529e-01 4.589648891483899540e-02 7.998946815651652997e-01 4.434260476954369201e-01 9.850053510925722566e-01 6.648626681529369309e-01 4.606293826856903140e-01 3.309042418210563774e-01 1.438901922508034614e-01 7.986559119276418484e-01 7.037818421334554042e-01 3.605119534240813772e-01 3.785959549258922641e-01 9.562491516841659100e-01 4.997955143590974147e-01 1.029540300938682762e-01 1.819017177001992502e-01 3.665425750262368831e-01 1.688063588370778412e-01 7.030735208313992901e-01 8.922375654244527610e-01 1.055706412056253152e-01 2.664739907746691561e-01 9.906029568647586325e-01 6.043845090140997911e-03 3.495786295043534775e-01 5.989441999519146131e-01 6.776147193866479679e-01 7.012991789852640601e-01 1.825838783477321536e-01 7.612293578749116385e-01 1.564769891240175292e-01 2.762157292905387251e-01 7.641900040015234818e-01
|
11 |
+
4.746013333880729768e-01 7.609202966712714788e-01 2.537820854162747830e-01 1.709362234877408460e-01 1.886635378734374813e-01 2.439567014093724229e-02 7.640304718272151741e-01 3.483216170435471382e-01 7.744289278738043514e-01 4.190437573644867353e-01 5.319091476394965934e-02 8.580130976087452233e-01 6.259446446786639529e-01 8.793213970773006150e-01 2.441023074890465994e-01 7.753405549489799098e-01 8.760187573193888300e-01 5.946480724009295393e-02 2.873093046571124631e-01 8.710837851946537924e-01 9.103181731924696596e-01 6.534637257615111272e-01 4.128420398577182793e-01 4.905858108576378607e-01 6.178275806701372108e-02 6.368043900016381320e-01 2.865296941219959148e-01 6.371773028539067241e-01 4.924322796636745325e-01 1.709313290387282080e-01 1.856892551689268700e-01 9.592782603102242289e-01 5.402593764193130976e-02 7.287312244390512506e-01 5.679467572000697073e-01 6.255587794305905724e-02 3.069660218141317953e-01 1.089960430557104232e-01 5.550748245336984965e-01 2.555948886689661803e-01 4.140925514039996980e-01 1.180376445052062628e-01 8.832322629884041820e-01 7.784546946701487169e-02 3.177678935473182698e-01 6.681804863429485764e-02 7.047099396645268854e-01 4.133897376851528582e-01 5.600656990480865627e-01 3.883995683475501837e-01 4.459430113152932362e-01 4.214077227574740681e-01 4.763369230200156235e-01 2.701480661168440545e-01 4.296286564389811824e-01 9.601402258758658936e-01 6.326999441846863359e-01 2.442086919688498670e-01 8.407708423957936938e-01 3.626867985638081437e-01 3.641441713291436733e-01 7.932397565989488530e-01 8.902073520619256941e-01 1.929173010337000838e-01 7.309376779324568973e-01 7.305852858337777977e-01 6.510197444582447313e-01 9.512661608643838695e-01 8.461467164366111016e-01 9.245490147941206605e-01 2.658844813385705663e-01 9.538758859344749208e-01 8.215517204998477041e-01 8.217795540390903097e-01 7.569662091300560780e-01 6.262685322871274218e-01 5.597770510574888725e-01 8.155720175123675197e-01 8.545688745180864965e-01 8.986051518529034610e-01 2.477911506572628708e-01 8.462580108996445860e-01 6.065941220995090255e-01 6.500490804973033665e-01 1.120463882674053169e-01 9.299049132942927010e-02 1.388364074229719858e-02 5.901199124540731367e-01 2.795110110544174464e-02 1.644097083463245124e-01 5.341029647603202646e-01 5.276816677181681570e-01 5.439849107754858304e-01 5.371677986392331405e-02 4.515163125788429488e-01 5.036243367087100964e-01 5.721818679625961801e-01 5.271368612400184617e-03 7.720961020546839304e-01 9.015383457479009266e-01
|
12 |
+
8.301526916287945701e-01 8.704609696144033348e-01 2.955689129581380303e-01 1.762209253489944727e-01 2.698172933050072553e-01 1.138095349991521399e-01 4.092588531860634760e-01 8.202978121681584467e-01 2.822241377079557356e-01 6.117376205659387223e-01 7.169923068016897938e-01 9.310256256264415331e-02 3.989664052931106708e-01 1.651874953308862803e-02 7.890202597932294282e-02 9.068686774810821305e-01 5.203866694486933842e-01 4.297748572844445336e-01 5.208786995443430712e-01 2.163224881365530816e-01 7.274307306357226111e-01 1.675784956180090823e-01 5.969822786565782691e-01 8.959750832846602453e-02 1.253794151891943764e-01 5.352628522116801291e-01 2.562706125890066300e-01 6.030433202137867044e-01 8.330717547440393833e-01 9.603613683422040914e-02 7.569714244468559450e-01 3.184801677796517128e-01 1.667069341164499896e-01 3.132470247801235619e-01 6.417752836394801097e-01 6.433909425912354152e-02 4.056860213146201710e-01 3.166772891331335327e-01 9.574059746098845247e-01 1.492907964460536974e-01 8.311513764927496162e-01 6.652928354977717396e-01 2.396804722185036374e-01 5.812361618600220270e-01 9.724228681350225445e-01 2.853983236378453414e-01 5.337719354896472979e-01 6.779446197712412081e-01 5.485102006140557540e-01 9.010109155962182648e-01 5.724439967467525037e-01 5.965540527411405947e-01 1.598667990086183321e-01 1.363934512727023041e-01 5.327536522697270405e-01 4.123866715061276222e-01 4.617251396918636841e-01 6.935944951381239898e-01 4.300337419593377453e-01 1.892407993760835128e-01 1.666936825594794724e-01 4.625634184864588772e-01 4.805197636774838355e-02 7.003542850133466224e-01 2.130226006716084974e-03 8.678863343041013367e-01 4.874478520451258623e-01 7.043560228741558848e-01 6.317719270475393722e-01 5.372392256296196766e-01 2.982649812986511995e-01 1.272558612133412037e-01 2.467337555730741983e-01 6.546893200021091097e-01 6.291921159383098150e-01 8.505920470407707379e-01 4.046520490181828578e-01 3.875732096593392795e-01 8.551517214319142024e-01 4.152602284179877090e-01 9.587779137989138611e-01 6.977437468944928112e-01 3.240620775541913634e-02 4.025873770391376061e-01 5.485549335619134270e-01 7.146066156157020455e-01 3.012702534568838519e-01 3.526414480395153594e-01 3.309707144485515284e-01 4.315687014460974913e-01 6.641934530697197747e-01 2.172886798352815507e-01 4.807480925564590057e-01 5.006795397998469177e-01 5.818100901154411586e-01 2.107716091585690732e-01 6.606606051140029301e-01 9.317629042790995797e-01 9.840326342340242061e-01 5.752000964817773898e-01
|
13 |
+
9.843444595454536872e-01 1.339523968066913540e-02 6.082172659959028671e-03 7.828244785439336662e-01 5.069653703872761819e-01 2.804896494365415327e-01 2.112385836660957139e-02 6.016479440778699228e-02 7.457477935084961818e-01 3.445503949245375397e-01 4.063494277166557200e-01 8.630275274433116817e-01 5.948396018456146850e-01 1.400867933474212457e-01 6.997522422654076646e-01 5.766519767930851081e-01 5.419976500582250889e-01 7.474121304089603735e-01 2.951600193008566686e-01 7.980170422334191827e-01 1.829036799578199757e-01 6.317636496261300749e-01 2.812612231140887431e-02 5.464747656105657381e-01 3.909873503320924204e-01 4.940850205957293406e-01 8.157850130814222611e-01 5.111092739445756150e-01 9.336823640685747439e-01 7.157105167170837445e-01 7.778989455994214097e-01 1.398722535910470466e-01 5.642653936300449091e-01 3.218717164845980028e-01 9.717427501967056402e-01 3.665791984428700134e-01 3.874321311211759156e-02 9.437600858738082188e-02 5.679526822961932231e-01 5.141385991358327079e-01 7.497840799582222715e-02 5.736515309094968318e-01 1.928132849879083954e-01 6.924244068001785823e-01 1.748389677952593146e-01 4.469577663506929532e-01 1.738527450963387455e-01 7.195287763517190793e-01 8.861150811892871682e-01 1.058443750714600506e-01 1.941789362229970894e-01 9.188374820700584422e-02 7.706736301449305104e-01 6.718642548609364828e-01 5.981029087121966237e-01 4.832880127232569434e-01 3.073688779938709148e-01 5.156312334804930009e-01 1.777418420119527553e-01 8.885462205165685079e-01 4.486254681289014723e-02 1.345398129556140132e-01 7.467627984379916484e-01 4.384565546058830643e-01 7.217750080760946263e-01 3.949550352625393890e-01 4.307950907642028593e-01 6.087680934849041270e-01 3.294516167246774874e-01 1.316682090209408962e-01 1.824857738754404046e-01 5.332379826483617524e-01 3.567136182864261151e-02 1.976220743086236631e-01 5.849349042822560296e-01 1.133174406357483344e-01 7.711522754393199675e-01 8.557306786807005183e-01 3.038353471344266143e-01 4.422747047768413875e-01 2.537160404215925702e-01 2.372714099723788328e-01 5.906462765375103396e-01 4.849909323133470007e-01 2.692576210504484813e-01 4.540849506602829821e-01 9.664935719107857759e-01 2.044371576459835804e-01 4.505417469690352616e-01 7.110722322201217249e-01 3.051357995214963870e-01 8.978937034341526457e-01 6.090501112506481185e-01 6.595415779178889215e-01 6.565426836745864581e-01 6.565608489824376059e-01 2.679102664248229626e-01 3.819533138204529443e-01 6.609794961162380744e-01 2.289558446859882856e-01
|
14 |
+
9.274935298374649140e-01 1.174096651033715855e-01 3.030761852629033637e-01 1.605508209527917174e-01 9.601854834873225775e-01 4.341959513718630648e-01 6.320768160802121560e-01 4.213429090614078110e-01 3.695553969042019160e-01 5.965457437116089556e-01 3.520335041155040479e-01 7.702703502247409961e-01 8.571112772962534709e-01 7.904077282532658844e-01 2.247339318352784554e-01 6.823720204503556097e-01 5.883435710582129996e-02 6.786037033312407596e-01 9.721137137641507886e-01 2.042576970668320557e-01 8.394085754806240862e-01 7.433082729552867862e-01 4.072614159870893147e-01 7.451483066617257123e-01 1.699472962789440045e-01 1.753052015584344314e-01 2.255269204788400428e-01 7.794755643807432799e-01 8.407732260470973662e-01 9.301182862857163558e-01 3.701995309382508648e-01 4.481909027604019657e-01 1.261889085033987001e-01 5.600591735875248833e-01 8.244692493969552061e-01 8.969188061645969601e-01 4.802217973423368313e-01 3.556164122713412201e-02 3.393317823164623270e-01 2.491242957582864292e-01 9.863253789366602797e-01 5.585415885291432625e-01 3.702350606362231344e-01 6.766101432620400535e-01 6.999259389475386284e-01 6.676108316872160220e-01 7.870681827507105544e-01 8.746765411259082024e-01 9.125268371282718727e-01 6.638849997061806452e-01 3.253268113800632522e-01 7.968625619248901337e-01 7.584122525443606211e-01 9.028886850768532701e-01 5.381622293189292083e-02 8.097562873320752752e-01 7.092942088208666895e-01 9.915538877968065323e-01 4.319294903327922652e-01 4.307127933969153721e-01 2.768507739641907772e-01 8.076253078288621046e-01 2.569233696442670967e-01 7.595893829724666979e-01 5.768081727897018673e-01 2.537536777625452045e-01 8.874419624636734616e-01 5.091705681832693342e-01 4.811826624992353585e-01 2.794462461940371290e-01 3.846927898276129021e-01 5.129562951959991679e-01 8.515004062224775794e-01 7.103144978683579858e-01 9.526388607201888847e-01 2.367905569592337889e-01 9.137336039323161740e-01 5.722969943101696710e-02 2.019723935481291255e-01 3.098764675203513619e-02 1.121146613918624357e-01 9.937693067724532314e-01 8.476717958861412772e-02 2.059652110343795917e-01 2.139791918759540446e-01 9.137860316709250919e-01 9.530862653366889425e-03 2.027843281683039400e-03 2.506229951837134484e-01 6.244523528392044165e-01 5.523937894075592325e-01 3.712168074031840792e-01 4.218847794299319665e-01 4.827576239387890711e-01 5.244634168840578425e-01 5.182241092381567604e-01 3.308639956263292881e-03 9.370528021570383448e-01 4.694554875029453012e-01 4.950447554541728135e-01
|
15 |
+
1.525818111800841814e-01 4.708012184002630107e-02 3.899035965341954846e-01 3.928304521031263929e-01 5.602286661727436945e-01 9.738256658043862313e-01 9.404465779766183475e-01 5.750862754958349088e-01 9.547546956257608741e-01 2.750275291553152535e-01 1.682773435862793265e-01 5.865928471016079726e-04 8.543378154943809255e-01 3.547649971465383079e-01 5.058056647397523031e-01 9.116332486700751137e-02 7.534666421106954726e-01 3.082429494433007733e-01 4.527145111847344916e-01 5.456680635225539255e-01 2.504131242494785914e-01 2.509240770568589296e-01 3.949236999582302898e-01 8.782959620323271821e-03 2.474641132111736752e-01 8.229417958971670943e-01 3.444225768479134420e-01 4.000027489436257522e-01 4.247741954177396417e-01 2.497745404169693373e-02 4.325768602588443423e-01 7.336592463477830117e-01 7.667663267650381975e-02 4.179022553581047683e-01 8.745172741480690126e-01 9.417705509525042817e-02 2.807522782799587446e-01 8.212710101351362590e-01 2.211181944001613386e-01 4.319929503523877168e-01 1.858636923768219873e-02 6.737037795085246694e-01 7.997187114913413275e-01 2.976552505976116647e-01 3.272347030789168887e-01 5.550935453236346406e-01 9.224109746648162522e-01 3.192827922106745708e-01 3.500098324549234530e-01 7.821988386980260888e-01 4.478417135239194380e-01 1.580956175222456572e-01 5.300807813550156844e-01 5.806154798468634581e-01 9.456842911054151868e-01 7.688127895655872956e-01 8.456527833650537840e-01 1.784229089865225770e-01 8.114517450321339087e-01 8.062506298824222428e-01 2.113482500442499523e-01 2.629226789210241666e-01 6.478686221690072022e-01 6.006672861605766300e-02 7.013679843242253131e-01 8.784753961212666828e-01 3.487138165323044880e-02 4.928426758517070461e-01 5.976224683315064512e-01 7.629063997052759616e-01 2.761721278953045422e-01 7.240740503283805696e-01 6.131065729985127888e-01 1.630885615792579957e-01 8.473783868551159060e-01 8.347614542399306448e-02 8.137265626844719657e-01 8.512508664918938539e-01 2.777097816703766320e-01 1.729154355214796990e-01 2.203382750835449766e-01 6.134780912629795857e-01 3.524352564238901753e-01 5.370314860129862256e-01 8.013986113284543578e-02 2.555842138998117852e-01 6.553915758947851389e-01 9.679125599178584061e-01 2.549566319678178150e-01 4.008180804370896633e-01 9.145789951670967310e-01 2.787926039163850511e-01 8.599455912576436933e-02 9.637558000691170967e-02 8.274101203974880692e-01 1.803747268179315411e-01 2.175735407836230095e-01 7.825994939720237742e-01 7.928519890958951599e-02 8.707949373106749213e-01
|
16 |
+
6.398420210047787160e-01 5.739624494012524059e-01 3.359672805578653998e-01 1.130399363175038641e-02 3.349439685346782269e-01 2.315484030880912147e-01 4.575228302577399875e-01 1.149494135594463229e-01 2.888244352925943836e-01 3.625470995156252485e-01 3.795973190611611203e-01 6.567047810450010736e-01 1.484039742710284715e-01 9.273251916560719676e-01 4.334256728976307871e-01 6.734771102219323513e-01 9.125080197222198430e-01 4.974393931097168542e-01 8.301481563280355136e-01 4.526450714147856047e-01 2.414236092573898151e-01 8.070129698367667359e-02 7.260400697427102923e-01 1.396509691839398215e-02 2.496450588391967429e-01 4.335741205447194435e-01 3.089314419194891803e-01 9.543503534526003307e-01 5.457977547458532364e-01 3.139663643587058406e-01 5.034762326753475792e-01 4.756788330475764104e-01 6.849334942793482428e-01 3.880666613022351052e-01 6.483446580176778218e-01 5.217503801099343530e-01 5.371145824070304720e-01 3.121260159429154468e-01 8.314121854062171968e-01 4.538695969561833410e-01 8.598896961203845724e-01 9.961993522734106099e-01 8.865717795946430613e-01 7.828987966783660379e-01 3.412415531643435695e-01 7.421170530151157685e-01 4.484104178639959359e-01 6.793217012099640462e-01 3.756179958191659951e-01 7.821287098222597933e-01 6.227726265188193722e-02 8.552983413221663112e-01 4.824668768009222619e-01 2.241531065858231031e-01 4.939536577599041856e-01 5.129566641128722182e-01 1.057984177672518511e-01 9.541452507300716146e-01 3.396646181755047511e-01 7.452588103611947901e-01 5.315559265659929311e-01 5.493475179850665358e-01 5.214824278139198466e-01 5.150075718147916204e-01 1.196075368500321146e-01 9.035665331176232495e-01 7.522653903639873185e-01 6.638708679914825384e-01 5.584174553800479446e-01 5.015819402508836511e-01 5.507698483308445248e-01 5.978677577011723976e-01 8.450418028759657529e-01 3.266677322748618995e-01 1.321610045897971819e-01 2.394354042746985600e-01 2.723972163557076831e-01 5.523301747352814539e-01 5.518043850608547185e-01 5.283968096837132755e-02 8.192733312104071297e-01 2.277106024970321219e-02 1.414998099027269252e-01 6.517281615256080851e-01 1.811694734825117781e-01 9.472370614713256920e-01 5.454497319021770485e-01 1.364119913158231556e-01 8.446142008509562871e-01 7.671725984742419069e-01 2.461161648406858804e-01 1.421724627107351369e-01 6.290652581179481118e-01 7.094144689448004248e-01 4.419656923472803367e-02 6.614741876652251440e-01 8.712193265403500586e-02 4.734931280852430202e-01 5.382037050480286133e-01 1.396459758005891283e-01
|
17 |
+
9.709329844415439670e-01 8.998575745276288229e-01 9.151313462895852568e-01 6.920489275523904471e-01 2.892231405199537919e-01 6.750679746268205550e-01 5.515642485826798280e-01 1.065253097812824956e-01 2.957026803465776510e-01 8.937347659632134400e-01 9.800016515925590310e-01 7.745900896182087436e-01 1.570977683146633774e-01 1.482028765821026273e-01 2.111147779712029271e-01 9.683759902485811200e-01 6.550951580826911425e-01 8.728324682592377703e-01 5.044803166579884257e-01 8.285704754811143991e-01 1.693574499337324735e-02 6.032669995180495182e-02 1.687026879086964692e-01 7.701554026145973619e-01 1.429888016593102718e-01 5.881172815379975827e-02 9.704206919487038396e-01 4.450807650730836951e-01 1.597445784258376689e-01 9.849229394397314152e-01 4.220083573536804744e-01 9.357693600374825671e-01 2.313199262338369033e-01 4.556443403861323294e-01 2.590791012828855822e-01 8.438664994487065085e-01 5.519045677502344427e-01 4.702170125676508050e-01 6.814723205638187897e-01 7.418295483665861001e-01 3.684921032028853904e-01 1.501895844844561845e-01 4.214513377519605308e-01 8.600279963652578408e-01 6.625616611189292238e-01 5.200151456470966105e-01 7.881072743086801058e-01 2.771703241081423519e-01 9.034135930616548071e-01 5.848441705791300738e-01 8.341698181274771473e-01 1.966638677318299777e-01 7.059747894371543042e-01 7.013854316067694716e-01 1.828430942760242983e-01 4.745548949934464966e-01 6.306422394641082452e-01 7.760751707194470939e-01 9.813187212598396547e-01 2.293595795266353266e-01 7.749261876107090830e-01 2.384106107787011819e-01 9.721209688979495223e-01 2.715569353686980714e-01 2.915573577694993146e-01 3.579601509630966349e-01 3.085697512342830962e-01 4.070219981627976047e-01 1.989632411372218579e-01 7.330003339460906542e-01 5.397259604481572381e-01 6.931009942216573849e-01 1.385457419653816080e-01 1.140339999976658358e-01 3.980752590866034613e-01 9.471822621683767540e-01 5.476643721405823895e-01 6.824131903515884279e-02 5.844099130744569992e-01 2.346881692012994236e-01 9.436439228519653000e-01 4.855518260479008141e-02 8.157036123302675579e-01 1.169761256455048581e-01 5.532962903488753970e-01 1.100965596251435308e-01 9.789490602992410029e-01 8.433487462016989733e-01 1.272410782852178013e-01 2.885715258680641160e-01 7.990943955388217779e-01 1.565305358979097727e-01 9.160846960406943129e-02 8.521842244411678147e-01 4.474243106736998099e-01 3.843945818845087015e-01 4.710645906071458944e-01 2.398348154123419729e-01 6.435351435258193087e-01 7.656897921129046658e-01
|
18 |
+
4.894328120406804539e-01 7.881019629214267574e-01 6.974585354155089512e-01 2.023858939857701156e-01 1.660984914264745926e-01 4.854517801734643534e-01 2.789848572630315715e-01 2.311636522410289718e-01 9.821076233980715608e-01 1.220641257408076052e-01 2.614036146663852866e-01 7.657560715165320220e-01 3.968360577545695378e-01 4.566023622802184434e-02 1.049701948619241598e-02 9.281162949127452766e-01 4.490137965769909201e-01 2.095846458383606725e-01 9.195504656719085679e-01 9.683515436855471004e-01 9.800174878114910060e-01 5.517610861380117804e-01 6.711570559348770670e-01 5.125258050287277989e-01 2.105581493613526423e-01 8.281813206544574868e-01 4.964783994807770995e-01 7.284974208756571645e-01 1.320629592816270348e-01 6.652194518096135045e-01 9.430156297917950958e-01 7.477263137894260003e-01 2.054087806450300979e-01 4.248209124837907247e-01 7.657518666018259257e-02 1.031614100713345028e-01 4.122242287567021712e-01 4.919658859336810686e-01 3.752650167259050651e-01 4.175771429986683270e-01 6.131376293448997927e-01 5.463797405837259591e-01 3.119918548921774004e-01 6.331762507678504459e-01 5.484632429281035559e-01 6.815448032785871302e-01 8.065695507425107991e-02 8.720129122297424207e-01 8.318188557125294480e-03 2.199323537180564170e-02 8.933872719887463454e-01 1.953120287872067706e-02 2.478721941404590234e-01 5.994061179859005994e-01 6.588362611693047155e-01 6.332808851020984564e-01 3.823849348043323326e-01 5.111091324899629251e-01 7.034808459110406531e-01 4.347681568463539481e-01 4.316973576672314961e-01 9.620411080123215664e-01 6.247837467655984467e-01 8.196961678222113301e-01 5.574601810887074294e-01 8.800635018469276094e-01 8.772255241161972528e-01 5.075275933138404527e-01 8.022583187266906224e-01 2.320670802521890286e-01 1.165626629103270195e-01 4.623759662685936744e-01 7.938327000737943617e-02 7.986374689793115378e-01 6.728842751465858862e-01 8.133909095059230765e-01 1.202639390769081329e-01 1.052937257108800262e-01 8.717600467040409473e-02 2.163819956545051104e-01 6.596483385763984852e-01 1.202843170392309258e-02 1.538789195854695091e-01 3.120247727263308901e-01 3.408168327248596308e-01 3.241861797851740556e-01 3.637074533655986208e-01 1.533669345890729119e-01 4.455921334699539660e-01 5.619140093874478437e-01 1.881731359879111887e-01 9.416670800570559052e-01 1.740018593664415247e-01 7.030242331869680505e-01 5.922055553954849172e-01 9.326211623391688077e-01 6.608322881013140027e-01 7.009721551241574478e-01 1.079126054675583202e-01 6.158176671761947940e-01
|
19 |
+
5.185079639625639336e-01 9.613742991518259284e-01 5.555312825626229634e-01 2.647628827924735084e-01 6.003697207460141350e-01 5.392112376769145898e-01 6.781186965667050925e-01 9.908971748181496508e-01 4.124155872095397468e-01 9.814941401724619485e-02 2.684237785531295994e-02 1.774652505962848181e-01 1.707589529595294753e-01 4.640932098465534450e-01 2.882179883914587348e-01 7.276822905806898945e-01 6.145789546745269449e-01 1.100959863917608805e-01 6.798859723042820491e-01 9.096984032948918220e-01 3.971368455178179158e-01 2.959494950971321980e-01 3.742088799298171065e-02 1.960739526210202310e-01 7.536102695342027369e-01 6.680915510628401277e-01 4.136507204312135366e-01 3.613996339406737590e-01 3.605422038261204554e-01 7.098503555159476619e-01 8.093719147087541366e-01 6.344097009128880638e-01 3.990082448083617228e-01 2.805918009906902544e-01 7.078488167363675698e-01 9.969917259866583059e-01 9.442054998992396309e-01 1.329075240769165278e-01 6.810681350588387861e-02 8.503491437913293094e-01 8.347117439165431252e-01 2.381858201903953587e-01 7.884260706938626129e-01 7.109907917419661105e-01 6.390916681983604963e-02 6.174365227062991179e-01 5.085733343630816083e-01 1.716846139694149231e-01 9.065664924270055991e-02 5.625330757196970177e-01 3.539663480209681579e-01 8.937139525947165319e-01 3.981380511900556307e-02 7.403597927449541150e-01 3.803872284089604427e-02 6.729519695709765825e-01 5.306080908840085097e-01 2.091237680402112664e-01 5.902903662907804661e-01 2.094778612095482551e-01 7.323447855684165342e-01 3.644574495843493356e-01 2.006215478057034041e-01 3.737617545555030896e-01 5.253471759602216240e-01 4.287889547869583318e-01 7.086098806190446187e-01 4.510792335515292351e-01 6.383187180169215269e-01 8.779355722397681472e-01 4.221338898667141848e-01 6.375840144651815367e-01 8.683057298299173832e-01 6.093730356952498095e-01 9.297141161056151626e-01 7.770838342807246946e-01 6.549661287008456956e-02 2.835060738158660110e-01 4.474138867374952699e-01 8.530336387421445510e-01 3.160209657891883683e-01 8.301538680518486535e-01 6.646903097549101691e-01 7.187130118106234145e-01 1.651862041735395747e-01 9.578252676762609719e-01 6.490273812885494209e-02 9.777273484666341163e-01 8.930729829254262508e-01 9.851054752118463265e-01 4.094323402286751401e-01 1.139176240124337713e-01 7.612865863899589414e-01 2.266379302491570158e-01 6.998882496157835531e-01 9.945043379099228753e-01 7.111578056749194854e-01 7.806190603886183910e-01 3.410170920712443099e-01 9.446084168886822452e-01
|
20 |
+
5.015172758330755931e-01 5.569527971282052237e-01 1.122406928736449094e-01 8.960352822124777461e-01 6.049568585854003810e-02 1.202196001338627918e-01 1.870314295763603196e-01 9.017590029396971296e-01 3.597904628087450485e-01 2.130941062746317671e-01 2.556281834629479111e-01 5.123669364829196438e-01 4.754061129282013409e-01 9.764470380372083369e-01 8.038663983900646848e-01 6.960491266420890666e-01 2.940135977911654264e-01 2.857282759910040326e-03 4.599343225832352999e-02 5.597554495210212977e-01 7.445266674304001908e-01 3.387528030535971180e-01 6.429542922125383031e-01 2.123331785532429627e-01 5.302332654117811739e-01 7.262555377662539557e-01 3.982425859900724507e-01 3.243388301740235402e-01 6.191064123738921898e-01 8.988047781373914580e-01 7.819700328765150088e-01 7.664269102804815992e-01 6.734095355422575757e-03 2.904762329148526945e-01 5.097537644843168625e-01 9.524734606001823423e-01 4.812869576591960463e-01 6.236868013640477493e-01 1.459170943214320726e-01 9.874505139403206844e-01 7.561708982837871407e-01 3.798591332432484924e-01 6.056633451375117438e-01 7.935708170258731764e-01 1.458141583518740569e-01 7.082511296391911237e-01 1.098798009731616343e-02 3.655618484905173160e-01 9.551862303858617009e-01 8.148959351152762487e-02 4.739306219219985294e-02 7.963357515359494876e-01 6.208332695202813944e-01 3.884182264923189409e-01 4.589167647950288531e-01 6.496652974138312775e-01 2.467528128074852889e-01 5.309593064844935206e-01 5.364606369543487574e-01 2.421352989851309756e-01 3.776834556696828660e-02 1.564861233558080267e-01 5.197231021782636740e-01 8.725375120634637494e-01 2.441225493455024820e-01 2.320363366041028330e-01 5.026358683423555185e-01 7.035766000474735771e-01 8.347805591467084563e-01 2.303229841813967393e-01 6.908373419683054850e-01 2.646662377366995056e-01 1.259467197942290007e-01 9.372770922994989595e-01 6.674216272867254940e-01 1.027944489143072238e-01 5.686267290346079806e-01 3.948222804451942958e-01 4.689706944496729868e-01 4.446117700449114807e-02 6.817992275557515081e-01 9.084821829413957106e-01 9.184021015315092518e-01 3.045815734169987632e-01 2.204958624923980537e-03 7.542672057172502553e-01 9.460844786545006269e-01 3.373139094575949848e-02 9.059565314915285494e-01 9.938525461318854504e-01 2.542072661725306437e-01 9.685734112479216229e-02 8.223629541824816203e-01 1.057429056898460118e-01 8.080679390260248063e-01 5.823014244609205914e-01 6.413551528031806725e-01 1.787341975438894170e-01 1.250471413912357388e-01 8.390281297596062782e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
4.0515260e+00 4.2121458e+00 3.7357405e+00 4.2313317e+00 3.9136009e+00 4.3843298e+00 3.9811426e+00 4.3624182e+00 4.0642508e+00 4.2105933e+00 4.0747226e+00 3.9068586e+00 4.1637004e+00 4.4303203e+00 4.1841564e+00 4.1063279e+00 4.1862390e+00 4.0719925e+00 4.2227579e+00 4.3173531e+00 3.8811067e+00 3.7577567e+00 4.0623722e+00 3.9882453e+00 4.0432671e+00 3.9085109e+00 4.0283414e+00 4.0846110e+00 3.6459235e+00 3.9544001e+00 4.1134244e+00 4.1805752e+00 3.5121011e+00 4.2747789e+00 4.1048323e+00 3.9269426e+00 3.8932032e+00 3.8281172e+00 3.7288430e+00 4.0863477e+00 4.1527428e+00 4.1646409e+00 4.2027433e+00 3.8441594e+00 4.8419117e+00 4.2455384e+00 3.7622220e+00 4.3967923e+00 4.4663183e+00 4.0435853e+00 4.0421692e+00 4.3124625e+00 4.6499961e+00 4.5595743e+00 3.4230430e+00 4.2612266e+00 3.5676603e+00 4.0866580e+00 4.2307103e+00 3.8521940e+00 3.9951183e+00 3.1022409e+00 3.7290193e+00 4.1931517e+00 4.1127027e+00 3.6633651e+00 4.0235815e+00 3.9729858e+00 4.1980132e+00 4.1579993e+00 3.9948955e+00 3.9081966e+00 3.9031152e+00 3.5069036e+00 4.0015727e+00 3.6763496e+00 3.6614339e+00 3.6227109e+00 3.7357992e+00 4.0170026e+00 3.5216829e+00 3.9322227e+00 3.9094621e+00 4.0170286e+00 4.3264246e+00 4.3435483e+00 4.0788635e+00 4.4761765e+00 3.8468186e+00 4.1490333e+00 4.2800007e+00 4.2260191e+00 4.3031858e+00 4.1897413e+00 4.0530244e+00 3.5893641e+00 4.2186615e+00 3.7979503e+00 4.0915473e+00 4.1343073e+00 4.5063851e+00 3.6394889e+00 4.2508448e+00 3.7160826e+00 4.0105262e+00 4.1578269e+00 4.0290590e+00 3.6971819e+00 3.9414087e+00 4.2522313e+00 4.4091714e+00 4.1542292e+00 3.9594691e+00 4.0923600e+00 4.0855497e+00 3.8253075e+00 4.3034717e+00 4.0976731e+00 4.1316523e+00 4.0872717e+00 4.2643353e+00 3.8887280e+00 3.9411273e+00 3.8848001e+00 4.3481996e+00 3.8716733e+00 3.9084684e+00 3.7546361e+00 3.9354816e+00 3.8293694e+00 3.7568515e+00 3.7184961e+00 3.8404278e+00 4.2570811e+00 4.1423777e+00 4.0291411e+00 4.2094682e+00 3.6127418e+00 4.0459839e+00 3.7737985e+00 3.7647653e+00 3.9762006e+00 3.8999512e+00 3.8509090e+00 3.8975941e+00 3.8432839e+00 4.2109046e+00 4.1339124e+00 3.5898873e+00 4.0794519e+00 4.3504966e+00 3.8862612e+00 3.8332931e+00 4.2190310e+00 4.1366595e+00 3.7220268e+00 4.1250795e+00 3.3169452e+00 4.0757181e+00 3.6487114e+00 3.9513724e+00 4.0735549e+00 3.9137880e+00 3.9656942e+00 3.7724953e+00 4.0505153e+00 3.9062302e+00 4.5671852e+00 3.7542175e+00 4.3731708e+00 3.6733907e+00 4.4667545e+00 4.1004635e+00 4.0530038e+00 4.0346958e+00 4.2145752e+00 4.4298637e+00 4.2982360e+00 4.0878239e+00 4.4061563e+00 4.2115971e+00 3.8263277e+00 3.8603258e+00 3.8572375e+00 4.1051910e+00 4.3787786e+00 4.5309659e+00 4.0047055e+00 4.1308854e+00 3.6283561e+00
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-hamming-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
4.6000000e-01 4.3000000e-01 4.3000000e-01 5.4000000e-01 4.1000000e-01 5.3000000e-01 4.3000000e-01 5.9000000e-01 4.8000000e-01 4.7000000e-01 4.6000000e-01 4.9000000e-01 4.5000000e-01 5.5000000e-01 5.3000000e-01 4.5000000e-01 4.8000000e-01 4.7000000e-01 4.8000000e-01 5.1000000e-01 4.9000000e-01 4.4000000e-01 4.9000000e-01 4.7000000e-01 4.9000000e-01 4.7000000e-01 5.2000000e-01 4.7000000e-01 4.2000000e-01 4.9000000e-01 4.7000000e-01 5.5000000e-01 3.9000000e-01 5.5000000e-01 4.6000000e-01 4.5000000e-01 4.0000000e-01 4.8000000e-01 4.5000000e-01 4.8000000e-01 4.8000000e-01 5.0000000e-01 4.8000000e-01 4.5000000e-01 6.4000000e-01 5.7000000e-01 4.6000000e-01 5.4000000e-01 5.6000000e-01 4.8000000e-01 4.8000000e-01 5.3000000e-01 5.4000000e-01 5.3000000e-01 4.5000000e-01 5.8000000e-01 4.2000000e-01 5.4000000e-01 6.0000000e-01 5.1000000e-01 4.6000000e-01 4.1000000e-01 4.4000000e-01 5.6000000e-01 5.4000000e-01 4.8000000e-01 4.8000000e-01 5.1000000e-01 5.2000000e-01 5.5000000e-01 4.5000000e-01 4.3000000e-01 4.7000000e-01 4.7000000e-01 5.6000000e-01 4.9000000e-01 4.8000000e-01 4.5000000e-01 4.9000000e-01 4.7000000e-01 4.5000000e-01 4.5000000e-01 5.6000000e-01 4.9000000e-01 5.8000000e-01 5.4000000e-01 4.6000000e-01 5.8000000e-01 5.3000000e-01 5.4000000e-01 5.5000000e-01 5.0000000e-01 5.2000000e-01 4.8000000e-01 5.0000000e-01 3.8000000e-01 5.3000000e-01 4.8000000e-01 5.1000000e-01 4.8000000e-01 5.2000000e-01 4.7000000e-01 5.0000000e-01 4.3000000e-01 4.8000000e-01 5.2000000e-01 5.0000000e-01 4.2000000e-01 4.2000000e-01 4.7000000e-01 5.4000000e-01 5.1000000e-01 5.4000000e-01 5.1000000e-01 4.8000000e-01 4.7000000e-01 5.2000000e-01 5.2000000e-01 5.4000000e-01 5.4000000e-01 5.0000000e-01 4.5000000e-01 4.4000000e-01 4.1000000e-01 5.7000000e-01 4.6000000e-01 5.1000000e-01 5.2000000e-01 5.0000000e-01 4.8000000e-01 5.0000000e-01 4.4000000e-01 5.3000000e-01 5.2000000e-01 4.9000000e-01 5.7000000e-01 5.8000000e-01 4.9000000e-01 5.1000000e-01 4.5000000e-01 5.3000000e-01 4.5000000e-01 4.4000000e-01 3.5000000e-01 4.2000000e-01 5.3000000e-01 5.2000000e-01 5.0000000e-01 3.8000000e-01 5.2000000e-01 5.6000000e-01 4.7000000e-01 4.4000000e-01 5.1000000e-01 5.7000000e-01 4.5000000e-01 5.7000000e-01 4.3000000e-01 5.1000000e-01 3.8000000e-01 5.3000000e-01 4.8000000e-01 4.4000000e-01 5.0000000e-01 4.8000000e-01 5.0000000e-01 4.7000000e-01 6.4000000e-01 4.9000000e-01 5.2000000e-01 4.8000000e-01 5.6000000e-01 4.3000000e-01 4.8000000e-01 4.7000000e-01 6.0000000e-01 5.4000000e-01 5.5000000e-01 4.0000000e-01 5.5000000e-01 5.6000000e-01 4.9000000e-01 5.0000000e-01 4.3000000e-01 5.7000000e-01 5.0000000e-01 5.7000000e-01 4.9000000e-01 4.2000000e-01 3.9000000e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-jaccard-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
6.5714286e-01 6.0563380e-01 6.3235294e-01 7.3972603e-01 6.0294118e-01 7.3611111e-01 6.4179104e-01 7.7631579e-01 6.4000000e-01 6.6197183e-01 6.6666667e-01 7.0000000e-01 6.4285714e-01 7.7464789e-01 7.1621622e-01 6.4285714e-01 6.8571429e-01 6.4383562e-01 6.6666667e-01 6.5384615e-01 6.6216216e-01 6.1971831e-01 6.5333333e-01 6.5277778e-01 6.7123288e-01 6.4383562e-01 6.5000000e-01 6.3513514e-01 6.0000000e-01 6.7123288e-01 6.3513514e-01 7.4324324e-01 5.5714286e-01 7.0512821e-01 6.3888889e-01 6.0000000e-01 5.6338028e-01 6.3157895e-01 6.0810811e-01 6.2337662e-01 6.4000000e-01 6.5789474e-01 6.3157895e-01 5.6962025e-01 7.5294118e-01 7.1250000e-01 6.2162162e-01 6.7500000e-01 7.2727273e-01 6.2337662e-01 6.2337662e-01 6.7948718e-01 6.5853659e-01 6.6250000e-01 6.3380282e-01 7.3417722e-01 6.0869565e-01 7.2000000e-01 7.5949367e-01 6.4556962e-01 6.3013699e-01 5.9420290e-01 6.2857143e-01 7.1794872e-01 7.3972603e-01 6.4864865e-01 6.4864865e-01 6.8918919e-01 6.6666667e-01 7.0512821e-01 6.2500000e-01 6.2318841e-01 6.6197183e-01 6.5277778e-01 6.9135802e-01 6.6216216e-01 6.6666667e-01 6.4285714e-01 6.6216216e-01 6.8115942e-01 6.2500000e-01 6.2500000e-01 7.3684211e-01 6.4473684e-01 7.3417722e-01 7.1052632e-01 6.3888889e-01 7.3417722e-01 6.5432099e-01 6.9230769e-01 7.1428571e-01 6.7567568e-01 6.7532468e-01 6.7605634e-01 6.5789474e-01 5.4285714e-01 6.9736842e-01 6.2337662e-01 6.6233766e-01 6.7605634e-01 7.0270270e-01 6.1842105e-01 6.7567568e-01 6.2318841e-01 6.7605634e-01 6.9333333e-01 7.1428571e-01 6.0000000e-01 6.0000000e-01 6.6197183e-01 6.9230769e-01 6.8000000e-01 7.2000000e-01 6.5384615e-01 6.5753425e-01 6.6197183e-01 7.1232877e-01 6.9333333e-01 7.5000000e-01 7.1052632e-01 6.7567568e-01 6.4285714e-01 6.0273973e-01 5.8571429e-01 6.9512195e-01 6.3013699e-01 6.8918919e-01 7.0270270e-01 6.6666667e-01 6.8571429e-01 6.6666667e-01 6.1111111e-01 7.0666667e-01 6.6666667e-01 6.5333333e-01 6.8674699e-01 7.0731707e-01 6.3636364e-01 6.3750000e-01 6.1643836e-01 6.5432099e-01 5.8441558e-01 5.8666667e-01 4.7297297e-01 5.5263158e-01 6.9736842e-01 6.9333333e-01 6.5789474e-01 5.7575758e-01 6.7532468e-01 7.0886076e-01 6.4383562e-01 5.8666667e-01 6.6233766e-01 7.5000000e-01 6.2500000e-01 7.7027027e-01 6.0563380e-01 6.8000000e-01 5.6716418e-01 6.7948718e-01 6.4864865e-01 6.1971831e-01 7.1428571e-01 6.5753425e-01 6.7567568e-01 6.6197183e-01 7.7108434e-01 6.6216216e-01 7.1232877e-01 6.4000000e-01 7.0886076e-01 6.0563380e-01 6.2337662e-01 6.2666667e-01 7.7922078e-01 7.2972973e-01 7.5342466e-01 5.7971014e-01 7.3333333e-01 7.0886076e-01 6.6216216e-01 6.4102564e-01 5.8904110e-01 7.3076923e-01 6.4102564e-01 7.1250000e-01 6.4473684e-01 5.9154930e-01 5.3424658e-01
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
0.320369972991 0.338972466 0.308199372323 0.3452431902 0.310024768313 0.357115225615 0.311131096357 0.357391534414 0.329718053755 0.347365921475 0.335272625287 0.336451560653 0.33015370606 0.369628769749 0.344499490029 0.321622508707 0.345377707016 0.321007207534 0.350728979121 0.32809430086 0.30207071308 0.291663252492 0.30760470102 0.315976639534 0.308132467187 0.313014586878 0.310463895925 0.321091616502 0.290044394125 0.322213459935 0.315509196522 0.3331114403 0.281071919202 0.320854431887 0.332190658438 0.299342730178 0.313528775154 0.310049073937 0.288821516545 0.307662081954 0.328387688508 0.317185603454 0.332046170365 0.291912213887 0.37870970117 0.336080073379 0.304593343921 0.330138983604 0.355071759299 0.311946140607 0.302025400768 0.330940761586 0.351140062502 0.354772884287 0.272605322053 0.327957349848 0.28871110366 0.320821172951 0.340976919806 0.30757488831 0.320975346884 0.252776262329 0.314549731907 0.326876483 0.337684418756 0.296520013735 0.31493077245 0.327721982167 0.325802862624 0.341908184107 0.300481749419 0.312499767894 0.301061762121 0.27665157989 0.3082566692 0.287466396145 0.288313694552 0.296629698731 0.283556095025 0.322489360684 0.280765581604 0.297958166613 0.313189657041 0.303470399659 0.348652898212 0.331594734387 0.299446687464 0.339047458559 0.286979246044 0.316326095312 0.321618884109 0.330065896317 0.324500638067 0.328300795872 0.309002568222 0.262587468469 0.31974123777 0.286316182293 0.321162329165 0.328160620315 0.356618051635 0.289733970648 0.344507756538 0.301485561986 0.335785898715 0.322635066518 0.331480718646 0.297897604494 0.306942928189 0.350843442517 0.342585296966 0.341311053315 0.306780105123 0.313401804298 0.319978145568 0.302460397612 0.346105758567 0.312802351189 0.331552275517 0.321624157344 0.318798118247 0.301906095501 0.301585920138 0.314556178985 0.333215221158 0.306929663844 0.317083256901 0.309667679181 0.306529028004 0.30865993751 0.296031907986 0.28742420979 0.311584483038 0.319043629504 0.330278008622 0.314466433681 0.327937382021 0.296448162218 0.307033121385 0.296391953011 0.292691206116 0.297146209653 0.307929858983 0.291863681454 0.307300188104 0.306597817799 0.34718100163 0.317436210259 0.29952626739 0.330762834707 0.334951064852 0.323806678898 0.296203706701 0.33398466797 0.344931265559 0.293948734727 0.332764639313 0.272651853935 0.317324315923 0.300493570867 0.307008231016 0.333263322802 0.31390648462 0.332416491248 0.314766869708 0.321015549211 0.322909289307 0.356882966656 0.310596945263 0.343939748528 0.286269629586 0.33173459898 0.323848483719 0.305841388975 0.319266258167 0.34012363898 0.3443280395 0.353885654057 0.320544729867 0.353280499623 0.315621795536 0.312176062734 0.301562130879 0.312061680573 0.312642847966 0.326222109701 0.357417912858 0.313083593142 0.334033412713 0.295630506074
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
2.0215050e+00 2.0988154e+00 1.8614681e+00 2.0510161e+00 1.9210911e+00 2.1323516e+00 1.9565454e+00 2.1029889e+00 1.9617871e+00 2.0544792e+00 2.0357408e+00 1.8811414e+00 2.0694693e+00 2.1245977e+00 2.0632165e+00 2.0452823e+00 2.0249330e+00 1.9635489e+00 2.0508580e+00 2.0838578e+00 1.9324052e+00 1.8224609e+00 1.9795343e+00 1.9536534e+00 1.9694910e+00 1.9075569e+00 1.9590397e+00 2.0022087e+00 1.8814000e+00 1.8884208e+00 1.9961121e+00 2.0215351e+00 1.7515769e+00 2.0756437e+00 2.0109476e+00 1.9234849e+00 1.9160076e+00 1.8550862e+00 1.7733640e+00 2.0071906e+00 2.0209542e+00 2.0616569e+00 2.0565503e+00 1.9083573e+00 2.2732431e+00 1.9975503e+00 1.9080072e+00 2.1437809e+00 2.1296295e+00 1.9739085e+00 1.9834166e+00 2.1078664e+00 2.2016840e+00 2.2080962e+00 1.7340579e+00 2.0549287e+00 1.7331748e+00 1.9559688e+00 2.0343364e+00 1.8736929e+00 1.9730416e+00 1.5308944e+00 1.8421831e+00 2.0174240e+00 2.0137378e+00 1.7956151e+00 1.9606596e+00 1.9074857e+00 2.0413879e+00 2.0070305e+00 1.9584677e+00 1.8977851e+00 1.9176239e+00 1.7067419e+00 1.9461927e+00 1.8431700e+00 1.8284576e+00 1.7778704e+00 1.8350329e+00 2.0175415e+00 1.7459063e+00 1.9242505e+00 1.8757370e+00 1.9312506e+00 2.0574808e+00 2.0894636e+00 1.9780203e+00 2.1374036e+00 1.8900436e+00 2.0273032e+00 2.0681953e+00 2.0234699e+00 2.0666449e+00 2.0663485e+00 1.9281402e+00 1.7846314e+00 2.0372479e+00 1.8831230e+00 2.0186015e+00 2.0193231e+00 2.2022665e+00 1.8145737e+00 2.0466545e+00 1.8092421e+00 1.9600687e+00 2.0322961e+00 1.9556364e+00 1.8266422e+00 1.9950345e+00 2.1038429e+00 2.1164145e+00 2.0188062e+00 1.8863331e+00 2.0006971e+00 1.9971068e+00 1.8771862e+00 2.1148855e+00 1.9570638e+00 1.9859615e+00 2.0030854e+00 2.0737344e+00 1.9739259e+00 1.9266524e+00 1.9200535e+00 2.1376689e+00 1.8944425e+00 1.9330553e+00 1.8561590e+00 1.9422954e+00 1.8874178e+00 1.8624808e+00 1.8265563e+00 1.8840519e+00 2.0515092e+00 2.0174226e+00 1.9771196e+00 2.0635988e+00 1.7334466e+00 1.9912604e+00 1.8915711e+00 1.8262636e+00 1.9369173e+00 1.9560446e+00 1.9549934e+00 1.9279230e+00 1.9021073e+00 2.0113391e+00 2.0305786e+00 1.8066806e+00 1.9656739e+00 2.1219217e+00 1.8820250e+00 1.8936826e+00 2.0565131e+00 1.9839441e+00 1.8553479e+00 1.9923760e+00 1.6393276e+00 1.9786440e+00 1.8274394e+00 1.9322611e+00 2.0404318e+00 1.9216532e+00 1.9361171e+00 1.8401373e+00 1.9908059e+00 1.9495117e+00 2.1975655e+00 1.8413913e+00 2.1528773e+00 1.8434374e+00 2.1668863e+00 2.0429273e+00 1.9980016e+00 1.9790129e+00 2.0264829e+00 2.1478843e+00 2.0899600e+00 2.0280670e+00 2.1210881e+00 1.9993891e+00 1.8646871e+00 1.9099983e+00 1.9263353e+00 2.0042495e+00 2.1365919e+00 2.1830279e+00 1.9631961e+00 2.0880004e+00 1.8348369e+00
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
env-llmeval/lib/python3.10/site-packages/scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|