c语言 rbinom函数,R - 二项分布( Binomial Distribution)

R - 二项分布( Binomial Distribution)

二项分布模型用于找出事件成功的概率,该事件在一系列实验中仅具有两种可能的结果。 例如,投掷硬币总是给出头部或尾部。 在二项分布期间估计在重复投掷硬币10次时准确找到3个头的概率。

R有四个内置函数来生成二项分布。 它们如下所述。dbinom(x, size, prob)

pbinom(x, size, prob)

qbinom(p, size, prob)

rbinom(n, size, prob)

以下是所用参数的说明 -x是数字的向量。

p是概率的向量。

n是观察次数。

size是试验次数。

prob是每次试验成功的概率。

dbinom()

该函数给出了每个点的概率密度分布。# Create a sample of 50 numbers which are incremented by 1.

x

# Create the binomial distribution.

y

# Give the chart file a name.

png(file = "dbinom.png")

# Plot the graph for this sample.

plot(x,y)

# Save the file.

dev.off()

当我们执行上面的代码时,它会产生以下结果 -

a975b3523dcb1d0623a98745fbc56df8.png

pbinom()

此函数给出事件的累积概率。 它是表示概率的单个值。# Probability of getting 26 or less heads from a 51 tosses of a coin.

x

print(x)

当我们执行上面的代码时,它会产生以下结果 -[1] 0.610116

qbinom()

此函数获取概率值并给出其累积值与概率值匹配的数字。# How many heads will have a probability of 0.25 will come out when a coin

# is tossed 51 times.

x

print(x)

当我们执行上面的代码时,它会产生以下结果 -[1] 23

rbinom()

此函数从给定样本生成给定概率的所需数量的随机值。# Find 8 random values from a sample of 150 with probability of 0.4.

x

print(x)

当我们执行上面的代码时,它会产生以下结果 -[1] 58 61 59 66 55 60 61 67

R - 正态分布( Normal Distribution)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值