numpy 和 scipy 中的因子 [英] Factorial in numpy and scipy

查看:79
本文介绍了numpy 和 scipy 中的因子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分别从 numpy 和 scipy 导入阶乘函数以查看哪个更快?

How can I import factorial function from numpy and scipy separately in order to see which one is faster?

我已经通过导入数学从 python 本身导入了阶乘.但是,它不适用于 numpy 和 scipy.

I already imported factorial from python itself by import math. But, it does not work for numpy and scipy.

推荐答案

您可以像这样导入它们:

You can import them like this:

In [7]: import scipy, numpy, math                                                          

In [8]: scipy.math.factorial, numpy.math.factorial, math.factorial
Out[8]: 
(<function math.factorial>,                                                                
 <function math.factorial>,                                                                
 <function math.factorial>)

scipy.math.factorialnumpy.math.factorial 似乎只是 math.factorial 的别名/引用,即is scipy.math.factorial is math.factorialnumpy.math.factorial is math.factorial 都应该给 True.

scipy.math.factorial and numpy.math.factorial seem to simply be aliases/references for/to math.factorial, that is scipy.math.factorial is math.factorial and numpy.math.factorial is math.factorial should both give True.

这篇关于numpy 和 scipy 中的因子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆