answersLogoWhite

0

/*************************************************************************/

/* POISSON3.C */

/* Calculate poisson statistics given average number of occurences */

/* and the value of interest. */

/* Uses the formula P(X=x) = mu^x * e^-mu/x!, for x = 1,2,3...x */

/* NOTICE: Factorial1() is copyrighted by author */

/* FURTHERMORE: Software is provided as is, with no promise of fitness */

/* for use. */

/* comments or questions: p_duke52@Yahoo.com */

/* Have fun... */

/* PAD, May 25, 2008 */

/*************************************************************************/ #include <stdio.h>

#include <math.h> /* protype of "e", exp(x) == exp^x */

#include <conio.h> /* For clrscr() */ /*********************************************************\

// copyrighted by author

// Written by: Jaco van Staden

// Date: 13 July 2002

// Program: Maths Program

// from the file "A_maths_me1067647162002.zip"

// available at Planet Source Code:

// http://www.planet-source-code.com

// changed int to double for size issues

// -- PAD, 5/25/08

\**********************************************************/ double Factorial1 (double a)

{

double answer = 1.0;

while(a>1)

answer *= a--;

return answer;

} int main(void)

{

double result, res1, res2;

double i = 0.0, k = 0.00;

double answer = 0.0; result = res1 = res2 = 0.0; clrscr(); /* makes it easier to see input prompts */ printf("Enter mean: ");

scanf("%lf", &i); printf("Enter value of interest: ");

scanf("%lf", &k); /* factorial of value of interest */ answer = Factorial1(k); /* formula for k */

result = pow(i,k);

res1 = 1/(exp(k));

res2 = (result * res1) / answer; printf("answer is ... : %0.20lf", res2);

return 0;

} /*************************************************************************/

/* POISSON3.C */

/* Calculate poisson statistics given average number of occurences */

/* and the value of interest. */

/* Uses the formula P(X=x) = mu^x * e^-mu/x!, for x = 1,2,3...x */

/* NOTICE: Factorial1() is copyrighted by author */

/* FURTHERMORE: Software is provided as is, with no promise of fitness */

/* for use. */

/* comments or questions: p_duke52@yahoo.com */

/* Have fun... */

/* PAD, May 25, 2008 */

/*************************************************************************/ #include <stdio.h>

#include <math.h> /* protype of "e", exp(x) == exp^x */

#include <conio.h> /* For clrscr() */ /*********************************************************\

// copyrighted by author

// Written by: Jaco van Staden

// Date: 13 July 2002

// Program: Maths Program

// from the file "A_maths_me1067647162002.zip"

// available at Planet Source Code:

// http://www.planet-source-code.com

// changed int to double for size issues

// -- PAD, 5/25/08

\**********************************************************/ double Factorial1 (double a)

{

double answer = 1.0;

while(a>1)

answer *= a--;

return answer;

} int main(void)

{

double result, res1, res2;

double i = 0.0, k = 0.00;

double answer = 0.0; result = res1 = res2 = 0.0; clrscr(); /* makes it easier to see input prompts */ printf("Enter mean: ");

scanf("%lf", &i); printf("Enter value of interest: ");

scanf("%lf", &k); /* factorial of value of interest */ answer = Factorial1(k); /* formula for k */

result = pow(i,k);

res1 = 1/(exp(k));

res2 = (result * res1) / answer; printf("answer is ... : %0.20lf", res2);

return 0;

}

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra

Add your answer:

Earn +20 pts
Q: C source code for poisson distribution?
Write your answer...
Submit
Still have questions?
magnify glass
imp