0
$\begingroup$

I have a data frame with 2 columns x,f that correspond to :

x : A measurement of the number of mosquitos that enter the room in a minute.

f : The number of occurrences of each number of mosquitos per minute within the set.

library(tidyverse)
x = seq(0,14,1);x
f = c(8,32,89,134,170,170,145,103,65,36,17,7,3,1,1)
df = tibble(x,f);df

Given that the x in the data frame follows Poisson distribution I have to calculate the lambda parameter :

> df%>%summarise(lambda = sum(x*f)/ sum(x))
# A tibble: 1 × 1
  lambda
   <dbl>
1  46.54


#or as.numeric

lam = as.numeric(df%>%summarise(lambda = sum(x*f)/ sum(x))) 
> lam
[1] 46.54286

and now I have to answer in 2 questions :

1) Find the probability that 40 mosquitos that will enter the room in 20 minutes.

2) Find the probability that the number of mosquitos that will enter the room in 5 minutes will be between 20 and 25.

How can I find these probabilities for question 1 and 2?

$\endgroup$
1
  • $\begingroup$ $46.54$ is totally implausible for the average rate, which clearly cannot exceed the maximum rate of $14$ and is likely to be closer to $5$; you have an error and should have summed the frequencies as in df%>%summarise(lambda=sum(x*f)/sum(f)) $\endgroup$
    – Henry
    Commented Oct 29, 2022 at 17:13

1 Answer 1

0
$\begingroup$

I think your calculation of $\lambda$ is incorrect. The variable x is the number of mosquitos entering the room per minute. The $i^{th}$ entry in f is the number of occurrences of the observation x[i]. So from what I understand, we see 0 mosquitos entering a room 8 times, 1 mosquito entering the room 32 times, and so on.

Hence, f are the weights of each of the x, and so $\lambda$ is estimated by

> sum(y*f)/sum(f)
[1] 4.981651

So $\hat{\lambda} = 4.98$.

  1. Find the probability that 40 mosquitos that will enter the room in 20 minutes.

The poisson distribution has the property that the sum of $n$ iid poisson random variables is also poisson distributed with rate parameter $n\lambda$. Hence, the rate parameter for this question is $20 \hat{\lambda}$.

Using R,

lam = sum(y*f)/sum(f)
dpois(40, 20*lam)
[1] 5.680858e-12

  1. Find the probability that the number of mosquitos that will enter the room in 5 minutes will be between 20 and 25.

I'm interpreting this as $p(20 \leq x \leq 25)$.

For this question, our rate parameter is $5\hat{\lambda}$. Using the cumulative mass function, $P$, we can compute this as

$$ P(25; 5\hat{\lambda}) - P(20; 5\hat{\lambda})$$

Where

In R

> ppois(25, 5*lam) - ppois(19, 5*lam)
[1] 0.4227893
$\endgroup$
6
  • 2
    $\begingroup$ Don't you think this is a homework question? In which case it wasn't the best idea to solve the OP's homework for them. $\endgroup$
    – dipetkov
    Commented Oct 29, 2022 at 13:45
  • 2
    $\begingroup$ @dipetkov When I was a student, I asked for help dozens of times on stack exchange. Often, I was given guided answers, but others I just got the answer right away. Sometimes seeing the solution can help clarify the process. I'm not advocating for always doing this, but I think once in a while it is OK to throw people a bone. $\endgroup$ Commented Oct 29, 2022 at 13:49
  • $\begingroup$ I actually think it's the OP's loss that you just gave them the answer. $\endgroup$
    – dipetkov
    Commented Oct 29, 2022 at 14:00
  • 2
    $\begingroup$ @dipetkov Then that's OP's problem. Learning from example is a legitimate strategy, and if OP doesn't want to use that and instead take the answer and run then I don't see why the onus should fall on the members of this community to rectify that. $\endgroup$ Commented Oct 29, 2022 at 14:33
  • $\begingroup$ Have you read the "Answering self-study questions" part of the self-study wiki? $\endgroup$
    – dipetkov
    Commented Oct 29, 2022 at 14:45

Your Answer

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