網站首頁 編程語言 正文
曲線一
解釋
這里是使用matplotlib來繪制正態分布的曲線。
代碼實現
import numpy as np import matplotlib.pyplot as plt def test1(n, m=500): out = [] result = np.random.normal(1, 5, n * m) print(result) for i in range(m): average0 = 0 for j in range(n): average0 += result[n * i + j] if j == n - 1: out.append(average0 / n) average0 = 0 print(out) plt.hist(out,bins=25) plt.title("test (1)") plt.xlabel("x") plt.ylabel("rate") plt.show() test1(5)
曲線二
解釋
這里使用了matplotlib.pyplot來實現指數分布的繪制,具體的代碼實現參見下面所示:
代碼實現
import numpy as np import matplotlib.pyplot as plt def test2(n, m=500): out0 = [] result0 = np.random.exponential(scale=1, size=n * m) # print(result0) for i in range(m): average000 = 0 for j in range(n): average000 += result0[n * i + j] if j == n - 1: out0.append(average000 / n) average000 = 0 # print(out0) plt.hist(out0,bins=25) plt.show() test2(5)
曲線三
代碼實現
import numpy as np import matplotlib.pyplot as plt def test3(n1, m111=500): out11 = [] # np.random.standard_t result11 = np.random.standard_t(1, size=n1 * m111) # print(result) for i in range(m111): average0 = 0 for j in range(n): average0 += result11[n1 * i + j] if j == n - 1: out11.append(average0 / n1) average0 = 0 # print(out11) plt.hist(out11,bins=20) plt.title("test (3)") plt.show() test3(30)
原文鏈接:https://blog.csdn.net/m0_54218263/article/details/123676513
相關推薦
- 2023-06-21 詳解C#中委托的概念與使用_C#教程
- 2022-07-16 SpringMVC 傳遞參數
- 2022-09-14 iOS實現簡單長截圖_IOS
- 2022-08-04 Python數據存儲之XML文檔和字典的互轉_python
- 2023-02-04 詳解如何在C#中接受或拒絕Excel中的修訂_C#教程
- 2022-09-25 apache+fastcgi如何使用Content-length和Transfer-Encoding
- 2023-12-13 記錄choice函數用法
- 2022-10-13 Python線性表種的單鏈表詳解_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支