Advertisement
TawratNibir

Possion random variable

Jan 28th, 2025
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. float poisson(int x, int y)
  4. {
  5.     if (y == 0)
  6.         return pow(2.718281828, (-x));
  7.     else
  8.     {
  9.         return ((float)x / y) * poisson(x, y - 1);
  10.     }
  11. }
  12. int main()
  13. {
  14.     int x, y;
  15.     cout << "Enter the value of x and lambda reopectively: \n";
  16.     cin >> x >> y;
  17.     float ans = poisson(x, y);
  18.     cout << "The result is: \n"
  19.          << ans;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement