# SciPy stats.kurtosis() function in Python

Hi, Welcome to this tutorial. Here we shall be studying the **SciPy.stats.Kurtosis() function** in Python.

**SciPy** is pronounced as “Sigh Pie”. It is an **open-source library** in Python which is used to perform technical, mathematical and scientific computations.

This** library contains several modules for optimization, linear algebra, integration, image processing, etc.**

The SciPy uses NumPy arrays as the fundamental data structure and contains several modules by which the above mentioned and several other scientific calculations can be implemented.

To learn more about SciPy library functionalities in Python, Click on the below links.

- Linear Algebra Computation – Linear algebra with Scipy module in Python
- Image Processing – Scipy image processing and manipulation through Python

**SciPy modules various sub-packages** like

** 1. Constants: **This contains physical constants and other conversions.

**2. Linalg:** This constitutes the routines of Linear algebra.

**3. Optimize:** This contains algorithms for linear programming.

**4**. **Signal:** This contains signal processing tools.

To learn about a few more sub-packages of SciPy,** Click Here**

## SciPy.stats.kurtosis() function in Python

Now Let’s learn about the** kurtosis() method.**

This function comes in the** Statistic Sub-package Of SciPy. **By this module, we can easily compute **statistical distributions and functions.**

One such is the ** Kurtosis** function. This function takes 5 parameters such as an array, axis, fisher, bias, nan_policy.

Kurtosis is the 4th central moment divided by (variance)^2. If we use Fisher’s definition then we need to subtract 3.0 from the result to give 0.0 for a normal distribution of a given data set.

Now, let us know about the parameters of the Kurtosis() method.

**1. a – array** –>This is the data set for which the Kurtosis is calculated.

**2.** **axis** –>This is the axis along which the Kurtosis is calculated. The default value is 0. It can be either int or none, optional. If None, the compute whole array ‘a’.

**3. fisher** –> It’s a boolean value. If true, then Fisher’s definition is used [normal–>0.0], otherwise Pearson’s definition is used [normal–>3.0].

**4. bias**–> It’s again a boolean value or optional. If False, then the computations are to be corrected using k statistics.

**5. nan_policy**–>It defines how to handle when nan input is present. It can take 3 values

**“propagate”**–returns nan,**“raise”**–throws an error,**“omit”**— calculates by ignoring nan values.- The
**default**is**“propagate”**.

The** Returning Value **of Kurtosis() function** is a **Kurtosis** array of values **along an axis**.**

If all the values are **Equal** then, for **Fisher’s definition it returns -3** and for **Pearson’s definition, returns 0.**

**Lets’s see an example. **

import scipy.stats as stats from scipy.stats import norm data = norm.rvs(size=1000) stats.kurtosis(data)

OUTPUT :

`-0.06926384300390558`

In the above example, the Kurtosis is close to zero as it is calculated from data given and not from any continuous distribution.

In Fisher’s definition, the Kurtosis value is zero for normal distribution as seen in the above example.

## Leave a Reply

You must be logged in to post a comment.