from scipy import stats as ss
时间: 2023-09-19 14:09:21 浏览: 43
The `scipy.stats` module provides a large number of probability distributions and statistical functions. Here's an example of importing `scipy.stats` and using the `norm` function to generate a normal distribution:
```
import scipy.stats as ss
# generate a normal distribution with mean=0 and standard deviation=1
dist = ss.norm(0, 1)
# calculate the probability density function at x=0
pdf_at_0 = dist.pdf(0)
# calculate the cumulative distribution function at x=1.96
cdf_at_1_96 = dist.cdf(1.96)
# generate a random sample of size 1000 from the distribution
sample = dist.rvs(1000)
```
In this example, we first create a `norm` object with mean 0 and standard deviation 1, which represents a standard normal distribution. We then use several methods of this object to calculate the probability density function and cumulative distribution function at specific values, as well as generate a random sample of size 1000 from the distribution.