<commit_before>//
//  MathUtilities.h
//  asutilities
//
//  Created by <NAME> on 9/15/17.
//
//

#ifndef MathUtilities_h
#define MathUtilities_h

namespace asu {

template <class DataT>
static inline size_t max_index( DataT *const input, const size_t size, float* value ) {
  size_t max = 0;
  for ( size_t i = 1; i < size; ++i ) {
    if ( input[i] > input[max] ) {
      *value = input[i];
      max = i;
    }
  }
  return max;
}

}

#endif /* MathUtilities_h */<commit_msg>Added mean and std calc<commit_after>//
//  MathUtilities.h
//  asutilities
//
//  Created by <NAME> on 9/15/17.
//
//

#ifndef MathUtilities_h
#define MathUtilities_h

namespace asu {

template <class DataT>
static inline size_t max_index( DataT *const input, const size_t size, float* value ) {
  size_t max = 0;
  for ( size_t i = 1; i < size; ++i ) {
    if ( input[i] > input[max] ) {
      *value = input[i];
      max = i;
    }
  }
  return max;
}

/**
 * Computes the mean
 */
template<class FTYPE>
inline typename FTYPE::value_type mean1D(const FTYPE& v) {
  typename FTYPE::value_type sum = std::accumulate(v.begin(), v.end(), 0.0);
  return sum / v.size();
}

/**
 * Computes the variance
 */
template<class FTYPE>
inline typename FTYPE::value_type variance1D(const FTYPE& v) {
  auto mean = mean1D(v);
  typename FTYPE::value_type sq_sum = std::inner_product(v.begin(), v.end(), v.begin(), 0.0);
  return (sq_sum / v.size() - mean * mean);
}


}

#endif /* MathUtilities_h */
{'fraction_non_alphanumeric': 0.15552523874488403, 'fraction_numerical': 0.01432469304229195, 'mean_word_length': 3.0191780821917806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4297290', 'n_tokens_mistral': 569, 'n_tokens_neox': 558, 'n_words': 150}