- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 243字
- 2021-07-15 17:15:13
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.
- Unreal Engine Physics Essentials
- Reporting with Visual Studio and Crystal Reports
- Moodle Administration Essentials
- Rust編程:入門、實戰(zhàn)與進階
- Cocos2d-x游戲開發(fā):手把手教你Lua語言的編程方法
- Web交互界面設(shè)計與制作(微課版)
- JavaScript+jQuery開發(fā)實戰(zhàn)
- 新手學(xué)Visual C# 2008程序設(shè)計
- GitLab Repository Management
- Python自然語言處理(微課版)
- MATLAB定量決策五大類問題
- Asynchronous Android Programming(Second Edition)
- Visual Foxpro 9.0數(shù)據(jù)庫程序設(shè)計教程
- 小程序,巧應(yīng)用:微信小程序開發(fā)實戰(zhàn)(第2版)
- PHP編程基礎(chǔ)與實踐教程