Program to implement standard deviation of grouped data | Function to find mean of grouped data . ; Function to find standard deviation of grouped data . ; Formula to find standard deviation deviation of grouped data . ; Declare and initialize the lower limit of interval . ; Declare and initialize the upper limit of interval . ; Calculating the size of array .
function mean ( mid , freq , n ) { let sum = 0 , freqSum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sum = sum + mid [ i ] * freq [ i ] ; freqSum = freqSum + freq [ i ] ; } return sum / freqSum ; } function groupedSD ( lower_limit , upper_limit , freq , n ) { let mid = [ ] ; let sum = 0 , freqSum = 0 , sd ; for ( let i = 0 ; i < n ; i ++ ) { mid [ i ] = ( lower_limit [ i ] + upper_limit [ i ] ) / 2 ; sum = sum + freq [ i ] * mid [ i ] * mid [ i ] ; freqSum = freqSum + freq [ i ] ; } sd = Math . sqrt ( ( sum - freqSum * mean ( mid , freq , n ) * mean ( mid , freq , n ) ) / ( freqSum - 1 ) ) ; return sd ; } let lower_limit = [ 50 , 61 , 71 , 86 , 96 ] ; let upper_limit = [ 60 , 70 , 85 , 95 , 100 ] ; let freq = [ 9 , 7 , 9 , 12 , 8 ] ; let n = lower_limit . length ; document . write ( groupedSD ( lower_limit , upper_limit , freq , n ) ) ;