1
$\begingroup$

Why

  1. pgeom(20,0.01,lower.tail = FALSE)
  2. 1-sum(dgeom(1:20,0.01))

produce different results in R? The result should be the same (at least in theory), right?

Output:

[1] 0.8097279 [1] 0.8197279

$\endgroup$

1 Answer 1

2
$\begingroup$

I think you just forgot to account for 0. We can have zero of failures in a sequence of Bernoulli trials before a success occurs.

> (1-sum(dgeom(0:20,0.01))) == pgeom(20,0.01,lower.tail = FALSE)
# [1] TRUE
$\endgroup$
2
  • $\begingroup$ Oh, you are right... thank you! $\endgroup$
    – keezar
    Commented Mar 1, 2020 at 0:08
  • 1
    $\begingroup$ Glad I could help! And welcome to the CV community. $\endgroup$
    – usεr11852
    Commented Mar 1, 2020 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.