In this problem you need to find the 5th and 95th percentiles of a Poisson distribution defined by parameter μ (the mean rate parameter).
What follows is just a longer introduction to the concepts, including two examples.
Say that you manage the inventory of a business for which orders on average come in at a known rate (daily, say), but for any given period the number of orders can be somewhat above or somewhat below the expected value. If it helps your motivation, you can imagine you're running a stall selling vegan sausages, or in booth handing out free beer, or at a barbecue serving pancakes, ....
The variable of interest, N, is the number of customers/orders within a given period — one day, let's say. The average rate multiplied by the period of interest yields the mean of the distribution (in this problem), which is the 'expected value', or average.
In this problem, N follows a Poisson distribution : N ~ Poisson(μ). So there is no influence of any external factors (weather, trends, etc.). The only parameter having a deterministic effect is μ.
Then the probability of having k customers in a period, given the expected number of customers in that period being equal to μ, is given by: Pr(N=k) = μ^k × exp(−μ) / k!
The caret (^) represents the power operator, and the exclamation mark (!) represents the factorial operation.
If μ and k are given, it is therefore straightforward to compute the probability, Pr(N=k), using the above formula.
However, in this problem you will be given μ, representing the mean ('expected') daily rate, and you thereby need to determine two values of k:
Hence, you will be sure that, in the long run, the number of customers you see each day will not often (no more than 10% of the time) be outside the range specified by the above two limits.
EXAMPLE 1:
% Input mu = 10 % Output lowerLimit = 4 upperLimit = 15 safeLimits = [lowerLimit upperLimit]
Note that the outputs shall be integers, because there is no physical meaning to 'half a customer'.
EXAMPLE 2:
% Input mu = 100 % Output lowerLimit = 83 upperLimit = 117 safeLimits = [lowerLimit upperLimit]
NOTE: the two limits are returned as the vector safeLimits, as shown.
NOTE: Toolbox functions are generally not available from within Cody.
David, Thanks for the problem. I really liked it. However poissinv([0.05 0.95],10) formula produces [5 15]. In the definition lowerlimit = 4 and upperlimit = 15. The poissinv function systematically produces one unit below the lower limits reported in the test suite.
It should be : The poissinv function systematically produces one unit above the lower limits reported in the test suite.
Hello, Mehmet OZC. Thanks for your kind words and interesting observation. . . . From the documentation: "X = poissinv(P,lambda) returns the smallest value X such that the Poisson cdf evaluated at X equals or exceeds P" — i.e. the associated probably would be ≥ P. . . . This won't generally satisfy the requirement in the present problem statement: "not be faced more than 5% of the time" — i.e. the associated probably must be ≤ 5%. That accounts for the difference that you noticed. . . .
Regards, DIV.
Thanks for your kind response. If you don't mind, I want to ask another question. When mu=10 first six cumulative probs are : [0.0 0.0 0.0 0.0103 0.0293 0.0671]. so cumulative prob for 5 isn't below 0.05. If I was not interested in the problem, I would not ask questions. I had to ask this one.
No problem: keep asking and we will all learn from it! . . . In "EXAMPLE 1" and the corresponding test in the Test Suite: mu = 10; lowerLimit = 4. For this lower limit the corresponding probability Pr(N≤4) satisfies my requirement that Pr(N≤k) ≤ 5%. That's why lowerLimit = 4 is the correct solution here. Indeed Pr(N≤0) et cetera would also satisfy that part of the requirement, but implicitly [sorry if it wasn't clear to everyone] the _largest_ value of k that satisfies Pr(N≤k) ≤ 5% is of most relevance. . . . As you noticed, Pr(N≤5) does not satisfy my requirement that Pr(N≤k) ≤ 5%. The "poissinv" function reports a value of k=5 because it instead finds the _smallest_ value of k that satisfies Pr(N≤k) ≥ 5% [note flipped inequality]. That is not consistent with the condition specified in the problem statement. . . . On the other hand, for the upper limit both the Test Suite and the "poissinv" function find the smallest value of k that satisfies Pr(N≤k) ≥ 95%. That's why there was no difference in results for upperLimit. . . . Of course, there is freedom to define other requirements in a different Cody problem. The requirements in this problem have a nice symmetry and consistency in never allowing the probability in either of the 'tails' to exceed 5%. On the other hand, the sum of the two 'tails' will typically be considerably less than 10% when using the values of lowerLimit and upperLimit specified here (e.g. only 7.8% for mu=10). For some purposes that might be seen as 'too conservative': choosing instead lowerLimit=5 would increase the sum of the two 'tails' to 11.6% — although it doesn't satisfy the strict requirements of the present problem, notice that it is closer to 10% (in this instance). . . . I hope that some of the above has addressed your question.
Given a window, how many subsets of a vector sum positive
645 Solvers
Are all the three given point in the same line?
161 Solvers
Create a random logical vector of N elements of which M are true.
76 Solvers
Determine the number of odd integers in a vector
302 Solvers
Molecule Atomic Wt (CHONS) Molecules
31 Solvers