求掷n颗骰子出现的点数和的数学期望与方差.matlab程序

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/02 09:38:14
求掷n颗骰子出现的点数和的数学期望与方差.matlab程序

求掷n颗骰子出现的点数和的数学期望与方差.matlab程序
求掷n颗骰子出现的点数和的数学期望与方差.matlab程序

求掷n颗骰子出现的点数和的数学期望与方差.matlab程序
Actually,there's an analytical solution to this.Let E() be expectation and S() be standard deviation in the following derivations.
For a single dice,
E(x) = (1+2+3+4+5+6)/6 = 3.5 and
S(x) = {[(1-3.5)^2+(2-3.5)^2+(3-3.5)^2+(4-3.5)^2+(5-3.5)^2+(6-3.5)^2)]/6}^0.5 = 1.71
For n dice,
E(nx) = 3.5n and
S(nx) = [(1.708^2)*n]^.5 = (2.917n)^0.5
Much faster than MATLAB and absolutely correct.