A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d9/d24/poisson__dist_8cpp.html below:

TheAlgorithms/C++: probability/poisson_dist.cpp File Reference

Loading...

Searching...

No Matches

Poisson statistics More...

#include <cmath>
#include <iostream>

Go to the source code of this file.

Poisson statistics

The Poisson distribution counts how many events occur over a set time interval.

Definition in file poisson_dist.cpp.

◆ fact()

Compute factorial of a given number

Definition at line 30 of file poisson_dist.cpp.

30 {

31 double x_fact = x;

32 for (int i = x - 1; i > 0; i--) {

33 x_fact *= i;

34 }

35

36 if (x_fact <= 0) {

37 x_fact = 1;

38 }

39 return x_fact;

40}

◆ main()

main function

Definition at line 65 of file poisson_dist.cpp.

65 {

66 double rate, expected;

68 std::cout << "Poisson rate : " << rate << std::endl;

69

71 std::cout << "Poisson expected : " << expected << std::endl;

72

74 << std::endl;

75 std::cout << "Poisson 0-8 successes : "

77

78 return 0;

79}

double poisson_x_successes(double expected, double x)

double poisson_rate(double events, double timeframe)

double poisson_expected(double rate, double time)

double poisson_range_successes(double expected, double lower, double upper)

◆ poisson_expected() double poisson_expected ( double rate, double time )

calculate the expected value over a time e.g rate of 2.5 over 10 mins = 2.5 x 10 = 25

Definition at line 25 of file poisson_dist.cpp.

25{ return rate * time; }

◆ poisson_range_successes() double poisson_range_successes ( double expected, double lower, double upper )

probability of a success in range for Poisson dist (inclusive, inclusive)

\[P = \sum_i p(\mu,i)\]

Definition at line 54 of file poisson_dist.cpp.

54 {

56 for

(

int

i =

lower

; i <= upper; i++) {

58 }

60}

std::string lower(std::string word)

function to convert a C++ string to lower case

◆ poisson_rate() double poisson_rate ( double events, double timeframe )

poisson rate:
calculate the events per unit time
e.g 5 dollars every 2 mins = 5 / 2 = 2.5

Definition at line 17 of file poisson_dist.cpp.

17 {

18 return events / timeframe;

19}

◆ poisson_x_successes() double poisson_x_successes ( double expected, double x )

Find the probability of x successes in a Poisson dist.

\[p(\mu,x) = \frac{\mu^x e^{-\mu}}{x!}\]

Definition at line 46 of file poisson_dist.cpp.

46 {

47 return

(std::pow(expected, x) * std::exp(-expected)) /

fact

(x);

48}


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4