官术网_书友最值得收藏!

Uniform distribution

Let's start off with a really simple example: uniform distribution. A uniform distribution just means there's a flat constant probability of a value occurring within a given range.

import numpy as np 
Import matplotlib.pyplot as plt 
 
values = np.random.uniform(-10.0, 10.0, 100000) 
plt.hist(values, 50) 
plt.show() 

So we can create a uniform distribution by using the NumPy random.uniform function. The preceding code says, I want a uniformly distributed random set of values that ranges between -10 and 10, and I want 100000 of them. If I then create a histogram of those values, you can see it looks like the following.

There's pretty much an equal chance of any given value or range of values occurring within that data. So, unlike the normal distribution, where we saw a concentration of values near the mean, a uniform distribution has equal probability across any given value within the range that you define.

So what would the probability distribution function of this look like? Well, I'd expect to see basically nothing outside of the range of -10 or beyond 10. But when I'm between -10 and 10, I would see a flat line because there's a constant probability of any one of those ranges of values occurring. So in a uniform distribution you would see a flat line on the probability distribution function because there is basically a constant probability. Every value, every range of values has an equal chance of appearing as any other value.

主站蜘蛛池模板: 淮阳县| 康乐县| 安义县| 平顶山市| 神农架林区| 郎溪县| 永春县| 高雄市| 濮阳市| 闻喜县| 阳山县| 基隆市| 乌审旗| 平乐县| 宁蒗| 宣城市| 新龙县| 吕梁市| 分宜县| 桂东县| 岫岩| 繁峙县| 西乡县| 繁峙县| 大城县| 兴业县| 万源市| 金沙县| 岐山县| 广东省| 鲁山县| 长葛市| 新蔡县| 西乡县| 八宿县| 祥云县| 渝北区| 镶黄旗| 靖边县| 浠水县| 巢湖市|