scipy.fftpack 和 numpy.fft 的区别

When applying scipy.fftpack.rfft and numpy.fft.rfft I get the following plots respectively:

Scipy:

Numpy:

While the shape of the 2 FFTs are roughly the same with the correct ratios between the peaks, the numpy one looks much smoother, whereas the scipy one has slightly smaller max peaks, and has much more noise.

===========================================================================

From NumPy's doc for rfft:

Returns:

out : complex ndarray

The truncated or zero-padded input, transformed along the axis indicated by axis, or the last one if axis is not specified. If n is even, the length of the transformed axis is (n/2)+1. If n is odd, the length is (n+1)/2.

It is not written explicitly but the "transformed data" is here complex.

From SciPy's doc for rfft

z : real ndarray

The returned real array contains:

[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2))]              if n is even
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)),Im(y(n/2))] if n is odd

Conclusion: the storage is different.

For a starter, look at the length of magnitude, it will be different in both cases. I give an example below for clarity:

In [33]: data = np.random.random(size=8)

In [34]: np.fft.rfft(data)
Out[34]:
array([ 3.33822983+0.j , 0.15879369+0.48542266j,
0.00614876+0.03590621j, -0.67376592-0.69793372j, 1.51730861+0.j ]) In [35]: scipy.fftpack.rfft(data)
Out[35]:
array([ 3.33822983, 0.15879369, 0.48542266, 0.00614876, 0.03590621,
-0.67376592, -0.69793372, 1.51730861])

The first element in both cases is the so-called "DC component" (the mean of the signal).

Then, you can recognize in the SciPy version the succession of real and imaginary parts of the NumPy version.

Difference between scipy.fftpack and numpy.fft的更多相关文章

  1. scipy.fftpack fft

    from scipy.fftpack import fft SciPy提供fftpack模块,可让用户计算快速傅立叶变换 例子: >>> a = np.arange(1,5) > ...

  2. SciPy fftpack(傅里叶变换)

    章节 SciPy 介绍 SciPy 安装 SciPy 基础功能 SciPy 特殊函数 SciPy k均值聚类 SciPy 常量 SciPy fftpack(傅里叶变换) SciPy 积分 SciPy ...

  3. scipy几乎实现numpy的所有函数

    NumPy和SciPy的关系?   numpy提供了数组对象,面向的任何使用者.scipy在numpy的基础上,面向科学家和工程师,提供了更为精准和广泛的函数.scipy几乎实现numpy的所有函数, ...

  4. numpy教程:快速傅里叶变换模块numpy.fft

    http://blog.csdn.net/pipisorry/article/details/51050297 快速傅里叶变换 NumPy中,fft模块提供了快速傅里叶变换的功能.在这个模块中,许多函 ...

  5. 使用 scipy.fft 进行Fourier Transform:Python 信号处理

    摘要:Fourier transform 是一个强大的概念,用于各种领域,从纯数学到音频工程甚至金融. 本文分享自华为云社区<使用 scipy.fft 进行Fourier Transform:P ...

  6. python数值计算模块NumPy scipy安装

    NumPy为Python提供了快速的多维数组处理的能力,而SciPy则在NumPy基础上添加了众多的科学计算所需的各种工具包,有了这两个库,Python就有几乎和Matlab一样的处理数据和计算的能力 ...

  7. Python下科学计算包numpy和SciPy的安装

    转载自:http://blog.sina.com.cn/s/blog_62dfdc740101aoo6.html Python下大多数工具包的安装都很简单,只需要执行 “python setup.py ...

  8. maya2105 - windows8 - numpy/scipy

    To compile numpy, create a site.cfg file in numpy's source directory with the following or similar c ...

  9. Windows下Python安装numpy+mkl,Scipy和statsmodels

    最近做时间序列分析需要用到Python中的statsmodels,但是安装过程中遇到很头疼的问题,Google.Stackover各种都没有找到合适的解决办法,而且貌似还有很多同学也在吐槽Window ...

随机推荐

  1. Vue 不睡觉教程2 - 洋气的文件结构

    目标书接上回,上回那个例子实在太土了.实际开发中我们不可能把整个网站的js和html全写到一个页面上.所以我们这节课的目标在于改造这个例子的文件结构,让它不那么土Let's do it 环境参数vue ...

  2. Sublime Text 3安装插件(Mac 10.12)

    1.先安装Package Control,默认这个是没有安装的. 使用[control + -]打开控制台,输入以下代码: import urllib.request,os; pf = 'Packag ...

  3. 同一个Activity先后加载2个Layout,从layout1取值传入layout2

    同一个Activity先后加载2个Layout,从layout1取值传入layout2 没啥技术含量,就权当丰富下mono for android的小代码. Main.xaml <?xml ve ...

  4. Linux系统编程:文件I/O编程

    文件I/O操作在Linux编程时是经常会使用到的一个内容,通常可以把比较大的数据写到一个文件中来进行存储或者与其他进程进行数据传输,这样比写到一个全局数组或指针参数来实现还要方便好多. 一.文件常用操 ...

  5. java.lang.IllegalStateException: Unknown Priority XXXX 的解决方法

    异常信息: java.lang.IllegalStateException: Unknown Priority SYS_ERR_SMS at org.apache.log4j.Category.pri ...

  6. JavaScript设计模式-13.组合模式

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. Vue单文件模板实例

    AddItemComponent.vue <template> <div id="add-item-template"> <div class=&qu ...

  8. Bunder: What does :require => nil in Gemfile mean?

    https://stackoverflow.com/questions/12200215/bunder-what-does-require-nil-in-gemfile-mean Require ni ...

  9. C#控件的Resize事件

    1. 当控件大小发生改变时,就会触发该事件 所以适合动态调整UI的布局, 例如: 国际化,不同语言导致控件长度不同: 控件的内容是动态增加的,也可以使用. 2.必须是大小会发生改变的控件才会触发该事件 ...

  10. PTA (Advanced Level) 1040 Longest Symmetric String

    1040 Longest Symmetric String (25 分) Given a string, you are supposed to output the length of the lo ...