 # Statistics and random variables

If I have an instrument system with 4 components and can function of at least two of them are working. Each component independently works with probability of 0.9.

How I can compute the probability that the system will function, using Rstudio functions?

It's a binomial probability distribution with p = 0.9. You need to add the values for x = 2:4.

``````# probabilities of 0-4 successes
dbinom(x = 0:4, size = 4, prob = 0.9)
#>  0.0001 0.0036 0.0486 0.2916 0.6561
``````

Created on 2020-11-16 by the reprex package (v0.3.0)

1 Like

but is pbinom or dbinom ?
p <- 0.8
n = 4
X <- 2:4
Prob <- pbinom(X, n, p)

They're basically the same, except pbinom gives the cumulative probabilities. You're less likely to make mistakes using dbinom.

``````# probabilities of x = 0-4 successes out of size = 4
size = 4
prob = 0.9
x <- 0:size
set.seed(123)

# probability density
d <- dbinom(x = x, size = size, prob = prob)
plot(x, d, main = "Probability of x successes")
`````` ``````# cumulative probability density
p <- pbinom(q = x, size = size, prob = prob)
plot(x, p, main = "Probability of x successes or less")
`````` ``````# inverse function
q <- qbinom(p = (0:100)/100, size = size, prob = prob)
plot(q, (0:100)/100, main = "Inverse cumulative density function")
`````` ``````# generate random numbers
r <- rbinom(n = 10000, size = size, prob = prob)
hist(r, main = "10000 Samples")
`````` Created on 2020-11-17 by the reprex package (v0.3.0)

1 Like

Ok, but why is 0:4 and not 2:4 ? 2 of them are working.

Yeah you just need to add the ones for 2:4.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.