引用来自ShangtongZhang的代码chapter08/expectation_vs_sample.py
通过一个简单的示例表现了使用expected 和sample update训练产生的相对误差
引入模块
1 | import numpy as np |
计算next state的sample和expect的均方误差
1 | # for figure 8.8, run a simulation of 2 * @b steps |
绘制图线,表征均方误差随抽样次数的变化
1 | def figure_8_8(): |
100%|██████████| 100/100 [00:00<00:00, 9047.05it/s]
100%|██████████| 100/100 [00:00<00:00, 2282.52it/s]
100%|██████████| 100/100 [00:00<00:00, 176.76it/s]
100%|██████████| 100/100 [00:20<00:00, 4.89it/s]