<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/768" rel="nofollow">http://projects.scipy.org/scipy/ticket/768</a> on 2008-10-31 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/pbrod/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/pbrod">@pbrod</a>, assigned to unknown.</em></p>
<p dir="auto">The generalized pareto cumulative distribution in standard form [1]_ is defined as:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="F(x;c) = 1-(1-c*x)**(1/c) for c&gt;0 and c&lt;0"><pre class="notranslate"><code class="notranslate">F(x;c) = 1-(1-c*x)**(1/c) for c&gt;0 and c&lt;0
</code></pre></div>
<p dir="auto">where c is the shape parameter.</p>
<p dir="auto">The limiting case as c-&gt;0 is the exponential cdf defined as</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="F(x;c=0) = 1-exp(-x)"><pre class="notranslate"><code class="notranslate">F(x;c=0) = 1-exp(-x)
</code></pre></div>
<p dir="auto">and is not implemented in the scipy.stats.distributions.genpareto distribution.</p>
<p dir="auto">To add this limiting case to scipy.stats.distributions.genpareto would<br>
greatly simplify statistical analysis. Through inference on the shape parameter, c,  the data themselves determine the most approprate type of tailbehavior and there is no need for making subjective a priori judgement of which individual extremevalue family to adopt.</p>
<p dir="auto">.. [1] Stuart Coles (2000),<br>
"An Introduction to Statistical Modeling of Extreme Values"</p>
<p dir="auto">As discussed here <a href="https://github.com/scipy/scipy/pull/337/files#r2227022">https://github.com/scipy/scipy/pull/337/files#r2227022</a> , Numpy's rfftn is not included in SciPy.</p>
<p dir="auto">However, SciPy's version of rfft (2 real results per frequency bin) behaves differently from numpy's (1 complex result per frequency bin), so it may be confusing to just import it side-by-side.</p>
<p dir="auto">In an old discussion, most people seem to agree that numpy's rfft output is superior:</p>
<p dir="auto"><a href="http://mail.scipy.org/pipermail/numpy-discussion/2006-September/022977.html" rel="nofollow">[Numpy-discussion] rfft different in numpy vs scipy, Sep 11 2006</a></p>
<p dir="auto">especially because that format matches the format for complex <code class="notranslate">fft</code> and works for N-dimensions, while SciPy's does not:</p>
<blockquote>
<p dir="auto">the <em>reason</em> why FFTW's r2c routines produce unpacked output is largely because "packed" formats do not generalize well to multi-dimensional FFTs, while the "unpacked" format does.</p>
</blockquote>
<p dir="auto">Does it make sense to replace Scipy's rfft with numpy's?  Or to rename it or make its output behavior an option, with numpy's behavior as default?</p>
<p dir="auto">Illustration:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: a = [9, -9, 1, 3]

In [2]: numpy.fft.fft(a)
Out[2]: array([  4. +0.j,   8.+12.j,  16. +0.j,   8.-12.j])

In [3]: numpy.fft.rfft(a)
Out[3]: array([  4. +0.j,   8.+12.j,  16. +0.j])

In [4]: numpy.fft.rfftn(a)
Out[4]: array([  4. +0.j,   8.+12.j,  16. +0.j])

In [5]: scipy.fftpack.fft(a)
Out[5]: array([  4. +0.j,   8.+12.j,  16. +0.j,   8.-12.j])

In [6]: scipy.fftpack.rfft(a)
Out[6]: array([  4.,   8.,  12.,  16.])"><pre class="notranslate"><code class="notranslate">In [1]: a = [9, -9, 1, 3]

In [2]: numpy.fft.fft(a)
Out[2]: array([  4. +0.j,   8.+12.j,  16. +0.j,   8.-12.j])

In [3]: numpy.fft.rfft(a)
Out[3]: array([  4. +0.j,   8.+12.j,  16. +0.j])

In [4]: numpy.fft.rfftn(a)
Out[4]: array([  4. +0.j,   8.+12.j,  16. +0.j])

In [5]: scipy.fftpack.fft(a)
Out[5]: array([  4. +0.j,   8.+12.j,  16. +0.j,   8.-12.j])

In [6]: scipy.fftpack.rfft(a)
Out[6]: array([  4.,   8.,  12.,  16.])
</code></pre></div>
<p dir="auto">Other confused people:</p>
<ul dir="auto">
<li><a href="http://stackoverflow.com/q/34788424/125507" rel="nofollow">Why does scipy.fftpack.rfft return real values? (SO, 2016)</a></li>
<li><a href="http://stackoverflow.com/questions/21517998/python-scipy-fftpack-rfft-frequency-bin-mapping" rel="nofollow">Python scipy.fftpack.rfft frequency bin mapping (SO, 2014)</a></li>
<li><a href="http://dsp.stackexchange.com/questions/14175/python-scipy-fftpack-rfft-frequency-bin-mapping" rel="nofollow">Python scipy.fftpack.rfft frequency bin mapping (DSP.SE, 2014)</a></li>
<li><a href="https://mail.scipy.org/pipermail/scipy-user/2009-February/020130.html" rel="nofollow">[SciPy-user] Numpy/Scipy rfft transformations do not match?, Feb 28 2009</a></li>
<li><a href="http://stackoverflow.com/questions/18537184/how-should-i-multiply-scipy-fftpack-output-vectors-together" rel="nofollow">How should I multiply scipy.fftpack output vectors together? (SO, 2013)</a></li>
</ul>