O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Approximating factorials with Cython

The last example is about approximating factorials with Cython. We will use two approximation methods. First, we will apply the Stirling approximation method (see http://en.wikipedia.org/wiki/Stirling%27s_approximation for more information). The formula for the Stirling approximation is as follows:

Approximating factorials with Cython

Secondly, we will use the approximation due to Ramanujan, with the following formula:

Approximating factorials with Cython

How to do it...

This section describes how to approximate factorials using Cython. In this recipe, we use types, which are optional in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required