Sort by

recency

|

104 Discussions

|

  • + 0 comments

    meanX = float(input()) value = int(input())

    p = ((meanX**value)math.e*(-meanX))/factorial(value)

    print("{:.3f}".format(p))

  • + 0 comments
    import math
    
    mean = 2.5
    k = 5
    
    p = pow(mean, k) * pow(math.e, -mean) / math.factorial(k)
    
    print(round(p, 3))
    
  • [deleted]
    + 0 comments

    Python Code :

    from math import factorial, exp
    
    miu = float(input())
    x = int(input())
    poisson_prob = ((miu ** x) * exp(-miu)) / factorial(x)
    print("%.3f" %poisson_prob)
    
  • + 0 comments
    from math import factorial as fc
    e, l, k = 2.71828, 2.5, 5
    print(f'{(l**k * e**-l) / fc(k):.3f}')
    
  • + 0 comments

    JS

      function factorial(n){
            if(n < 0){
                return -1;
            }
            if(n == 0 || n == 1){
                return 1;
            }else{
                return n * factorial(n-1);
            }
        }
        let value = input.split(/[\n]/g);
        let x = parseFloat(value[0]);
        let y = parseFloat(value[1]);
        let ans = (Math.pow(x,y) * Math.exp(-x))/factorial(y);
        console.log(ans.toFixed(3));