<commit_before>#!/bin/bash
#
# A basic floating point math library
#
# This file is part of the Alfred Bundler, released under the MIT licence.
#
# Copyright (c) 2014 The Alfred Bundler Team
#
# See https://github.com/shawnrice/alfred-bundler for more information.

###############################################################################
### Math Functions to help with color calculations
###############################################################################

#######################################
# Finds the max value among a set of numbers
# Globals:
#   None
# Arguments:
#   numbers
# Returns:
#   The largest number
#######################################
function Math::Max() {

  local numbers
  local i
  local max
  local len

  numbers=($@)
  i=0
  max=''
  len=${#numbers[@]}

  while [[ $i -lt $len ]]; do
    if [ -z ${max} ]; then
      max="${numbers[$i]}"
    fi

    if [[ $(echo "${numbers[$i]} > ${max}" | bc -l ) -eq 1 ]]; then
      max="${numbers[$i]}"
    fi

    : $[ i++ ]
  done;

  echo $max
}

#######################################
# Finds the min value among a set of numbers
# Globals:
#   None
# Arguments:
#   numbers
# Returns:
#   The lowest number
#######################################
function Math::Min() {

  local numbers
  local i
  local min
  local len

  numbers=($@)
  i=0
  min=''
  len=${#numbers[@]}

  while [[ $i -lt $len ]]; do
    if [ -z ${min} ]; then
      min="${numbers[$i]}"
    fi

    if [[ $(echo "${numbers[$i]} < ${min}" | bc -l ) -eq 1 ]]; then
      min="${numbers[$i]}"
    fi

    : $[ i++ ]
  done;

  echo $min
}

#######################################
# Finds the mean value of a set of numbers
# Globals:
#   None
# Arguments:
#   numbers
# Returns:
#   The average of the numbers
#######################################
function Math::Mean() {

  local numbers
  local i
  local total
  local len

  numbers=($@)
  i=0
  total=0
  len=${#numbers[@]}
  while [[ $i -lt $len ]]; do
    total=$(( total + ${numbers[$i]} ))
    : $[ i++ ]
  done;
  if [[ "${total}" -eq 0 ]]; then
    echo "Total ${total}"<commit_msg>fixed mean function to add floats<commit_after>#!/bin/bash
#
# A basic floating point math library
#
# This file is part of the Alfred Bundler, released under the MIT licence.
#
# Copyright (c) 2014 The Alfred Bundler Team
#
# See https://github.com/shawnrice/alfred-bundler for more information.

###############################################################################
### Math Functions to help with color calculations
###############################################################################

#######################################
# Finds the max value among a set of numbers
# Globals:
#   None
# Arguments:
#   numbers
# Returns:
#   The largest number
#######################################
function Math::Max() {

  local numbers
  local i
  local max
  local len

  numbers=($@)
  i=0
  max=''
  len=${#numbers[@]}

  while [[ $i -lt $len ]]; do
    if [ -z ${max} ]; then
      max="${numbers[$i]}"
    fi

    if [[ $(echo "${numbers[$i]} > ${max}" | bc -l ) -eq 1 ]]; then
      max="${numbers[$i]}"
    fi

    : $[ i++ ]
  done;

  echo $max
}

#######################################
# Finds the min value among a set of numbers
# Globals:
#   None
# Arguments:
#   numbers
# Returns:
#   The lowest number
#######################################
function Math::Min() {

  local numbers
  local i
  local min
  local len

  numbers=($@)
  i=0
  min=''
  len=${#numbers[@]}

  while [[ $i -lt $len ]]; do
    if [ -z ${min} ]; then
      min="${numbers[$i]}"
    fi

    if [[ $(echo "${numbers[$i]} < ${min}" | bc -l ) -eq 1 ]]; then
      min="${numbers[$i]}"
    fi

    : $[ i++ ]
  done;

  echo $min
}

#######################################
# Finds the mean value of a set of numbers
# Globals:
#   None
# Arguments:
#   numbers
# Returns:
#   The average of the numbers
#######################################
function Math::Mean() {

  local numbers
  local i
  local total
  local len

  numbers=($@)
  i=0
  total=0
  len=${#numbers[@]}
  while [[ $i -lt $len ]]; do
    total=$(echo "scale=10; $total + ${numbers[$i]}" | bc -l )
    : $[ i++ ]
  done;
  if [[ "${total}" == "0" ]]; then
{'fraction_non_alphanumeric': 0.3261792452830189, 'fraction_numerical': 0.005660377358490566, 'mean_word_length': 3.431556948798328, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1673468', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1291, 'n_words': 411}