function runTrials(f, n = 10000) {
  values = [];
  for (var ii = 0; ii < n; ii++) {
    values.push(measure(f));
  }
  return values.reduce((a, b) => a + b, 0) / n;
}
// measure the function run n times, return the mean
measure the function run n times, return the mean
measure the function run n times return the mean
function runTrials(f, n = 10000) {
  values = [];
  for (var ii = 0; ii < n; ii++) {
    values.push(measure(f));
  }
  return values.reduce((a, b) => a + b, 0) / n;
}
function runTrials ( f , n = 10000 ) { values = [ ] ; for ( var ii = 0 ; ii < n ; ii ++ ) { values . push ( measure ( f ) ) ; } return values . reduce ( ( a , b ) => a + b , 0 ) / n ; }
measure the function run n times, return the mean
measure the function run n times return the mean