均匀分布和正态分布

您所在的位置:网站首页 均匀分布和正态分布 均匀分布和正态分布

均匀分布和正态分布

2024-04-18 23:53| 来源: 网络整理| 查看: 265

做数据的时候经常会用到均匀分布和正态分布,通过画图来详细看一下区别。

# !/usr/bin/env python # -*-coding:utf-8 -*- """ # Time :2022/5/16 1:39 # Desc :uniform and normal distribution test. """ import numpy as np import matplotlib.pyplot as plt if __name__ == '__main__': L = 10000 indices = np.linspace(0, L, L) uni_dist = np.random.uniform(-5, 20, L) nor_dist = np.random.normal(loc=5, scale=10, size=L) plt.hist(nor_dist, bins=100, color="blue", label="normal") plt.hist(uni_dist, bins=100, color="red", label="uniform") plt.grid() plt.legend() plt.xlabel("snr") plt.ylabel("prob") plt.show()

结论:

正态分布范围会更广,在均值处对称集中;

均匀分布只在限定范围内,范围小,均匀分布;



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3