Sort by

recency

|

423 Discussions

|

  • [deleted]
    + 0 comments
    def stdDev(arr):
        # Print your answers to 1 decimal place within this function
        s = sum(arr)
        l = len(arr)
        mean = s/l
        
        a=[]
        
        for i in range(l):
            ans = abs(arr[i]-mean)
            new_ans = ans*ans
            a.append(new_ans)
        
        new_sum = sum(a)
        standard = new_sum / l
        answer = math.sqrt(standard)
        print(f"{answer:.1f}")
    
  • + 0 comments

    Javascript

    function stdDev(arr) {
        const sum = arr.reduce((acc, cur) => acc + cur, 0);
        const mean = sum / arr.length;
        console.log(Math.sqrt([...arr].reduce((acc, curr) => acc + Math.pow(curr - mean, 2), 0) / arr.length).toFixed(1))
    }
    
  • + 0 comments
    def stdDev(arr):
        m=sum(arr)/len(arr)
        l=[(arr[i]-m)**2 for i in range(len(arr))]
        print(round((sum(l)/len(arr))**0.5,1))
    
  • + 0 comments

    **python **

    def stdDev(arr):
        m=statistics.mean(arr)
        l=[]
        for i in arr:
            l.append((i-m)**2)
        print((statistics.mean(l))**0.5)
    
  • + 0 comments
    #python
    def stdDev(arr):
        s=0
        for x in arr:
            s=s+(x-sum(arr)/len(arr))**2
        print(round((s/len(arr))**.5, 1))