python-scipyHow do I use Python and SciPy to generate a Gaussian distribution?
The SciPy library provides a number of functions for generating a Gaussian distribution. To use Python and SciPy to generate a Gaussian distribution, the following steps need to be taken:
- Import the SciPy library:
import scipy.stats as stats
- Generate the Gaussian distribution using the
stats.norm()function. The function takes three parameters: mean, standard deviation and size. For example, to generate a Gaussian distribution with mean 0 and standard deviation 1, use:
x = stats.norm(0, 1).rvs(1000)
- Plot the Gaussian distribution using the
matplotliblibrary.import matplotlib.pyplot as plt
plt.hist(x, bins=30, density=True) plt.show()
The output will be a histogram of the generated Gaussian distribution:

## Helpful links
- [SciPy Documentation](https://docs.scipy.org/doc/scipy/reference/index.html)
- [Matplotlib Documentation](https://matplotlib.org/3.2.1/contents.html)More of Python Scipy
- How do I use Python Numpy to read and write Excel (.xlsx) files?
- How can I use Python and SciPy to find the zeros of a function?
- How do I create a 2D array of zeros using Python and NumPy?
- How do I use Scipy zeros in Python?
- How do I use Python XlsxWriter to write a NumPy array to an Excel file?
- How do I use Python Scipy to perform a Z test?
- How can I use Python and Numpy to zip files?
- How to use Python, XML-RPC, and NumPy together?
- How can I use Python Numpy to select elements from an array based on multiple conditions?
- How can I use Python and SciPy together online?
See more codes...