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. js继承(自备水,这非常干货)

    讲js继承之前,想一想什么是继承? 生活中有很多例子,比方说继承财产,继承女朋友的前男友的前女友 ヽ(ー_ー)ノ ,这些和js继承差不多,但是有一个不一样的地方,就是继承过后,原先的人就没有了,js继 ...

  2. datetime之 utcnow 和now的用法

    from datetime import datetime print(datetime.now()) 本地时间 print(datetime.utcnow()) 国际时间

  3. 阿里云 下载的 apache 证书 转换为 pcks8 证书

    第一步: 百度 搜索  rsa 转 pcks8 将 .key 文件 转换成 pcks8.key . 第二部: 将 chain.crt 的 内容 复制到 public.crt 下方.. 新的 publi ...

  4. 【性能调优】:记录一次数据库sql语句性能调优过程

    一,依旧很简单的一个接口,查询列表接口,发现10并发单交易场景下,数据库表4w铺底数据,每次查询2000条数据进行orderby显示,平均响应时间2秒以上,数据库的cpu使用率高达95%: 二,抓到这 ...

  5. swagger注释API详细说明

    API详细说明 注释汇总 @RequestMapping此注解的推荐配置 value method produces 示例: @ApiOperation("信息软删除") @Api ...

  6. android studio2.3.3 模拟器 Jni函数调用C++对象,lldb调试this指针和相关变量显示无效的原因

    android studio2.3.3 的版本中 Jni函数调用C++对象,对象调用相关的成员函数, lldb调试,变量跟踪窗口,this指针和相关变量显示无效的原因,但这些参数实际是有效的,只是de ...

  7. html5与html4区别

    1.声明方法简化,doctype.meta 2.有些元素可以省略标记,body.tbody... 3.新增语义化标签,<section><article>...<arti ...

  8. 【es6】数组扩展

    只有一个参数,为数组中的值.

  9. jenkins创建构建任务

    构建项目类型 点击 Jenkins 首页 “创建一个新任务” 的链接, 输入任务名称 Jenkins 提供了六种类型的任务. 构建一个自由风格的软件项目 这是Jenkins的主要功能.Jenkins ...

  10. Freemarker不显示对象的属性

    Freemarker不显示对象的属性 今天使用Freemarker在springboot项目中通过模板生成一些html文件.但是发现没有显示对象的属性. 找了很长时间,终于发现不显示对象的属性可能是两 ...