# Generating Poisson Distributions for a Fixed Number of Events

조회 수: 1 (최근 30일)
mttxc12 2015년 8월 8일
답변: Ghada Saleh 2015년 8월 10일
I'm wondering if there's a straight forward way to generate a poisson distribution for a distribution for a fixed number of events. For example, I have a vector of means for a poisson distribution; something like this: B=[3, 5, 7, 9, 10] Each element in B is the mean number of events I can expect to observe in that bin when I model the data in each bin as a poisson distribution. If I want to simulate observations of this distribution I can use the command poissrnd: poissrnd(B) Which generates a random vector. I now want to generate observations but I'd like to have control over the total number of events that are observed. Is there a straight forward way to do that?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Hello,
In order to have a pre-specified number of observations, you use the command
a = poissrnd(b,n,m)
where 'b' is an element of the 'B' vector you specified and 'n x m' is the dimension of the number of observations.
I understand that you want to do that directly to all the elements in 'B'. You can define 'B' as a cell array and then use the 'cellfun' to apply 'poissrnd' function to each element in 'B' as follows:
B = {3, 5, 7, 9, 10}
A = cellfun(@(x) poissrnd(x,3,5),B,'UniformOutput',0)
Now element 'i' in 'A' i.e., A{i} contains '3 x 5' Poisson observations with parameter B{i}.
I hope this helps,

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Poisson Distribution에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by