How to generate random variables in C that conform to a Poisson distribution?

Updated on science 2024-05-13
7 answers
  1. Anonymous users2024-02-10

    1) In the Poisson distribution, when finding the value of x, when p(x=k) is the maximum, set it to pxmax

    At this time, this is the same as solving for f(x)=lamda k k!There is a maximum value when k is taken, although this problem is somewhat difficult, but in the program it is possible to go through a loop to get the integer independent variable xmax when f(x) is taken as the maximum.

    2) Through iteration, the random number on the 0-1 interval is continuously generated, when the random number = c ) x ++while ( b >= c );

    return x;

  2. Anonymous users2024-02-09

    by Poisson distribution formula.

    You can roll out the relationship between the anterior and post.

    In this way, the K+1 item can be rolled out from item k. Now, let's analyze how to calculate random numbers that conform to a Poisson distribution. For the integer k from 1 to positive infinity, rand() a decimal place each time, if less than p(x=k), k is output, and k is a value that conforms to the Poisson distribution.

    Repeat the above steps n times to obtain n random numbers that conform to the Poisson distribution. pseudo-** form: p = exp(-lamda); for k = 0 ->infinity randvalue = rand(); if( randvalue < p) cout = 3 * lamda) to prevent the case that cannot be found"---");}" : "+k);

  3. Anonymous users2024-02-08

    Is it to find the probability of a Poisson distribution?

    I wrote about finding the probability of a Poisson distribution.

    #include

    #include

    #define e

    void main()

    int k,i,re=1;

    float u,p;

    scanf("%f %d",&u,&k);

    for(i=1;i<=k;i++)

    re=re*i;

    p=(float)pow(e,-u)*pow(u,k)/re;

    printf("p=%f",p);

  4. Anonymous users2024-02-07

    Step 1: Generate a lot of (0,1) evenly distributed random numbers (you can look up the table, but the general software can be directly adjusted) set to x1, x2, x3, x4, x5...

    Step 2: Assuming that the Poisson distribution parameter to be simulated is , calculate e (-Step 3: Take x1* x2*xk >= e^(-x1* x2* .x(k+1)

    k is the first random number generated, and then remove the k+1 numbers used above, and repeat the above steps.

    For example, x1*x2 >= e (-but x1*x2*x3 < e (-then the first random number is 2, and then multiply by x4 and repeat the above steps to produce the second random number.

    #include

    #include

    #include

    #include

    double rand()

    int prand(double n)

    while(t >= n);

    return y;

    void main()}

  5. Anonymous users2024-02-06

    I think this statement of yours is very strange in terms of probability.

    If you want to generate it:

    n = poissrnd(5,5,4)/10n =

  6. Anonymous users2024-02-05

    See how this program handles: function x=poisondist(x0,lamda,n)format long; x=zeros(n,1);for i=1;n; b=1; tol=1; k=0; while tol==1 r=mixmod(x0,10,1); b=b*r(10); if b

  7. Anonymous users2024-02-04

    Zero-means unit variance is not correlated with a sequence of measurable random variables.

    normrnd(0,1,1,n)

    0 is the mean. The first 1 standard deviation.

    n is the sequence length, or you can also normrnd(0,1) claim one at a time.

    The zero-mean variance is an uncorrelated white noise sequence.

    Variance》 sigma=

    normrnd(0, ,1, n)

    Same as above.

Related questions
8 answers2024-05-13

Isn't it over if you do a division of seconds?

15 answers2024-05-13

In the standard output of the C++ language, there are hexadecimal, decimal, and octal output formats, but there is no binary output format. So if you want to output binary, you can only write your own functions for output. >>>More

6 answers2024-05-13

#include

void main() >>>More

12 answers2024-05-13

How to use Eclipse to automatically generate getters, setters, and constructors. >>>More