question: public static double mean ( double [ ] data , int opt ) { if ( opt == 0 ) { int numData = 0 ; double mean = 0 ; for ( int i = 0 ; i < data . length ; i ++ ) { if ( ! Double . isNaN ( data [ i ] ) ) { mean += data [ i ] ; numData ++ ; } } mean /= numData ; return mean ; } else { int numData = 0 ; double mean = 0 ; for ( int i = 0 ; i < data . length ; i ++ ) { if ( ! Double . isNaN ( data [ i ] ) ) { mean += Math . log ( data [ i ] ) ; numData ++ ; } } mean = mean / numData ; return Math . exp ( mean ) ; } }
target:  Compute the mean of all elements in the array. this function can deal with NaNs