博客
关于我
02.中心极限定理验证
阅读量:456 次
发布时间:2019-03-06

本文共 978 字,大约阅读时间需要 3 分钟。

"""中心极限定理指的是给定一个任意分布的总体。我每次从这些总体中随机抽取 n 个抽样,一共抽 m 次。 然后把这 m 组抽样分别求出平均值/和。 这些平均值/和的分布接近正态分布。"""import numpy as npimport matplotlib.pyplot as plt# 1 给定任意分布的总体population = np.random.randint(0, 100, 100000)# 2 随机抽取m个样本,抽取n次def sample_choice(population, sample_num, sample_size):    samples = []    for i in range(sample_num):        sample = []        for j in range(sample_size):            unit = np.random.choice(population)            sample.append(unit)        samples.append(sample)    return samples# 3 计算样本均值def samples_mean(samples):    sample_mean = []    for i in range(len(samples)):        sample_mean.append(np.mean(samples[i]))        return sample_mean# 4 中心定理结果def central_limit_theorem():    # 1.任意分布总体    population = np.random.randint(0, 100, 100000)    # 2.抽样    samples = sample_choice(population, 1000, 50)    # 3.求样本均值    sample_mean = samples_mean(samples)    plt.hist(sample_mean, bins=30)    plt.show()if __name__ == "__main__":    central_limit_theorem()

 

转载地址:http://hekbz.baihongyu.com/

你可能感兴趣的文章
mysql5.7命令总结
查看>>
mysql5.7安装
查看>>
mysql5.7性能调优my.ini
查看>>
MySQL5.7新增Performance Schema表
查看>>
Mysql5.7深入学习 1.MySQL 5.7 中的新增功能
查看>>
Webpack 之 basic chunk graph
查看>>
Mysql5.7版本单机版my.cnf配置文件
查看>>
mysql5.7的安装和Navicat的安装
查看>>
mysql5.7示例数据库_Linux MySQL5.7多实例数据库配置
查看>>
Mysql8 数据库安装及主从配置 | Spring Cloud 2
查看>>
mysql8 配置文件配置group 问题 sql语句group不能使用报错解决 mysql8.X版本的my.cnf配置文件 my.cnf文件 能够使用的my.cnf配置文件
查看>>
MySQL8.0.29启动报错Different lower_case_table_names settings for server (‘0‘) and data dictionary (‘1‘)
查看>>
MYSQL8.0以上忘记root密码
查看>>
Mysql8.0以上重置初始密码的方法
查看>>
mysql8.0新特性-自增变量的持久化
查看>>
Mysql8.0注意url变更写法
查看>>
Mysql8.0的特性
查看>>
MySQL8修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查看>>
MySQL8修改密码的方法
查看>>
Mysql8在Centos上安装后忘记root密码如何重新设置
查看>>