Program to implement standard error of mean | C ++ Program to implement standard error of mean . ; Function to find sample mean . ; loop to calculate sum of array elements . ; Function to calculate sample standard deviation . ; Function to calculate sample error . ; Formula to find sample error . ; Driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; float mean ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; return sum / n ; } float SSD ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) ; return sqrt ( sum / ( n - 1 ) ) ; } float sampleError ( float arr [ ] , int n ) { return SSD ( arr , n ) / sqrt ( n ) ; } int main ( ) { float arr [ ] = { 78.53 , 79.62 , 80.25 , 81.05 , 83.21 , 83.46 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << sampleError ( arr , n ) ; return 0 ; }