on-internet
← Community

R returns FALSE when comparing a value to its printed output (rounding?)

Stack Overflow ·

Say I am looking for the probability of 4 successes out of n trials where Pr[success]=0.2. Using the binomial equation, I get 0.08808038. The code below shows two successful attempts at this: # find probability of 4 successes out of n trials where Pr[success] is 0.2 # "manually" using the binomial formula p_s <- 0.2 nT <- 10 x <- 4 (res1 <- choose(n = nT, k = x) * (p_s^4) * ((1-p_s)^6)) # returns 0.08808038 as expected (res2 <- dbinom(x = x, size = nT, prob = p_s)) # returns 0.08808038 as expected But when I use dbinom() on a vector and look at the value for x = 4 and compare it with the numbe

Comments

Sign in or sign up to comment and upvote.

No comments yet.