python-scipyHow do I use Python Scipy to generate distributions?
Python Scipy can be used to generate distributions by using the scipy.stats
module. For example, to generate a normal distribution with mean 0 and standard deviation 1, you can use the following code:
from scipy.stats import norm
# Generate random numbers from N(0,1)
data_normal = norm.rvs(size=1000,loc=0,scale=1)
The norm.rvs
function takes the following parameters:
size
: The number of random variables to generateloc
: The mean of the distributionscale
: The standard deviation of the distribution
You can also generate other distributions such as binomial, poisson, gamma, and many more. For more information, please refer to the Scipy documentation.
More of Python Scipy
- How do I use Python XlsxWriter to write a NumPy array to an Excel file?
- How do I create a 2D array of zeros using Python and NumPy?
- How do I use Python and SciPy to create a tutorial PDF?
- How can I use Python Scipy to zoom in on an image?
- How can I use Python and SciPy to extrapolate data?
- How do I convert a Python Numpy array to a list?
- How can I use Python and Numpy to parse XML data?
- How to use Python, XML-RPC, and NumPy together?
- How do I use Python Numpy to read and write Excel (.xlsx) files?
- How do I calculate variance using Python and SciPy?
See more codes...