R语言
runif(n,min,max)//从min~max选随机数n次
f <- c("sheep","car")//c像是数组?值是sheep和car
sample(f,n,prob=c(99,1),replace=TRUE)//从f中抽样n次,replace=TRUE表示抽样后返回,
//prob表示抽样的概率为99比1
plot(1:100000,f,type='o',col='red',log="x")//依据f的值划线,1:100000是f的大小 用R估算的值
result<-runif(100000,0,2)
f=c(1:100000)
if(result[1]*result[1]<=2) f[1]<-1
for (i in 2:100000){
f[i] <- f[i-1]
if(result[i]*result[i] <= 2) f[i]<- f[i]+1
}
for(i in 1 : 100000)
f[i] <- f[i] / i * 2
plot(1:100000,f,type='o',col='red',log="x") 计算二项分布是概率,
是实验次数,
是
次实验中发生了
次
sum(dbinom( 0:m , n , p))
计算泊松分布
sum(dpois(0:m,λ))
上海得物信息集团有限公司公司福利 1200人发布
