question: public static double variance ( double [ ] data , int opt ) { double mean = 0 ; double S = 0 ; double numData = 0 ; for ( int i = 0 ; i < data . length ; i ++ ) { if ( ! Double . isNaN ( data [ i ] ) ) { double delta = data [ i ] - mean ; mean += delta / ( numData + 1 ) ; S += delta * ( data [ i ] - mean ) ; numData ++ ; } } if ( opt == 0 ) return ( S / ( numData - 1 ) ) ; else return ( S / numData ) ; }
target:  Compute the variance in the array. This function can deal with NaNs