<commit_before>#ifndef HOIST_STATISTICS_H_
#define HOIST_STATISTICS_H_

#include <algorithm>
#include <cmath>
#include <iterator>
#include <map>
#include <type_traits>
#include <vector>

namespace hoist {
namespace statistics {

template<class InputIt>
double arithmetic_mean(InputIt first, InputIt last)
{
    using namespace std;
    static_assert(is_arithmetic<decltype(*first + *last)>::value);

    return accumulate(next(first), last, *first) /
        static_cast<double>(distance(first, last));
}

template<class InputIt>
double median(InputIt first, InputIt last)
{
    using namespace std;
    static_assert(is_arithmetic<decltype(*first + *last)>::value);

    auto sorted = vector<typename InputIt::value_type>(distance(first, last));
    partial_sort_copy(first, last, begin(sorted), end(sorted));

    auto range = sorted.size() - 1;
    auto it = next(begin(sorted), range / 2);
    return (static_cast<double>(*it) + *next(it, range & 1)) / 2;
}

template<class InputIt>
auto mode(InputIt first, InputIt last) -> typename InputIt::value_type
{
    using namespace std;

    auto counter = map<typename InputIt::value_type, std::size_t>{};
    while (first != last) {
        ++counter[*first];
    }
}

template<class InputIt>
double standard_deviation(InputIt first, InputIt last)
{
    using namespace std;
    static_assert(is_arithmetic<decltype(*first + *last)>::value);

    auto avg = arithmetic_mean(first, last);

    auto sorted = vector<typename InputIt::value_type>(distance(first, last));
    transform(first, last, begin(sorted),
            [avg](decltype(*first) val) { return pow(val - avg, 2); });

    return sqrt(arithmetic_mean(begin(sorted), end(sorted)));
}

}
}

#endif /* HOIST_STATISTICS_H_ */<commit_msg>Add error message for static asserts, remove stub method<commit_after>#ifndef HOIST_STATISTICS_H_
#define HOIST_STATISTICS_H_

#include <algorithm>
#include <cmath>
#include <iterator>
#include <map>
#include <type_traits>
#include <vector>

namespace hoist {
namespace statistics {

#define NOT_ARITHMETIC "Iterable value type must be arithmetic"

template<class InputIt>
double arithmetic_mean(InputIt first, InputIt last)
{
    using namespace std;
    static_assert(is_arithmetic<decltype(*first + *last)>::value, NOT_ARITHMETIC);

    return accumulate(next(first), last, *first) /
        static_cast<double>(distance(first, last));
}

template<class InputIt>
double median(InputIt first, InputIt last)
{
    using namespace std;
    static_assert(is_arithmetic<decltype(*first + *last)>::value, NOT_ARITHMETIC);

    auto sorted = vector<typename InputIt::value_type>(distance(first, last));
    partial_sort_copy(first, last, begin(sorted), end(sorted));

    auto range = sorted.size() - 1;
    auto it = next(begin(sorted), range / 2);
    return (static_cast<double>(*it) + *next(it, range & 1)) / 2;
}

template<class InputIt>
double standard_deviation(InputIt first, InputIt last)
{
    using namespace std;
    static_assert(is_arithmetic<decltype(*first + *last)>::value, NOT_ARITHMETIC);

    auto avg = arithmetic_mean(first, last);

    auto sorted = vector<typename InputIt::value_type>(distance(first, last));
    transform(first, last, begin(sorted),
            [avg](decltype(*first) val) { return pow(val - avg, 2); });

    return sqrt(arithmetic_mean(begin(sorted), end(sorted)));
}

#undef NOT_ARITHMETIC

}
}

#endif /* HOIST_STATISTICS_H_ */
{'fraction_non_alphanumeric': 0.1331577407082236, 'fraction_numerical': 0.0029265437518290896, 'mean_word_length': 5.071047957371226, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 38, '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': '2724468', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1098, 'n_words': 260}