Sort by

recency

|

71 Discussions

|

  • + 0 comments

    R: cat(round(pnorm(9800, mean=49*205, sd=sqrt(49)*15),4),fill=TRUE)

  • + 0 comments
    #python
    import math
    def cdf(m, std, x):
        return 0.5 * (1 + math.erf((x-m)/(std*2**.5)))
    n, m0, std0, x=49, 205, 15, 9800
    m=n*m0
    std=math.sqrt(n)*std0
    print(round(cdf(m, std, x), 4))
    
  • + 1 comment
    import math as m
    def cdf(mn, std, x):
        return 1/2 * (1 + m.erf((x-mn)/(std*m.sqrt(2))))
    print(f'{cdf(205*49, 15*m.sqrt(49), 9800):.4f}')
    
  • + 0 comments
    double maxLimit = 9800;
    int n = 49;
    
    double mean = 205;
    double stdDev = 15;
    
    double meanX = n * mean;
    double stdDevX = Math.sqrt(n) * stdDev;
    
    double p = probability(meanX, stdDevX, maxLimit);
    

    Explanation

    If you need to calculate whether the sum of random values fit the limit then you need:

    • multiply the mean in number of random values;
    • multiply standard deviation in the square root of number of random values;
    • the probability is calculated in the same way as in the previous problem.
  • + 0 comments

    JS

       function erf(x) {
            var a1 = 0.254829592;
            var a2 = -0.284496736;
            var a3 = 1.421413741;
            var a4 = -1.453152027;
            var a5 = 1.061405429;
            var p = 0.3275911;
            var sign = 1;
            if (x < 0) {
                sign = -1;
            }
            x = Math.abs(x);
            var t = 1.0 / (1.0 + p * x);
            var y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * Math.exp(-x * x);
            return sign * y;
        }
        let arr = input.split(/[\n]/g);
        let h = parseFloat(arr[0]);
        let b = parseFloat(arr[1]);
        let c = parseFloat(arr[2]);
        let std = Math.sqrt(b) * parseFloat(arr[3]);
        let res = 0.5 * (1+ erf((h - (b * c)) / (std * Math.sqrt(2))));
        console.log(res.toFixed(4));