<commit_before>class Array
  def average
    reduce(:+).to_f / size.to_f
  end

  def self.restore_avg(avg, count, delta=0.5, precision=2)
    res = []
    count.times do |t|
      res << (Random.rand(avg-delta...avg+delta)).round(3)
    end
    if res.average != avg
      diff = (res.average - avg)    
      res.map! { |el| (el - diff).round(precision) }
    elsif precision != 2
      res.map! { |el| el.round(precision) }      
    end
    return res
  end

end
<commit_msg>Fix round situation when we have 1st shot in<commit_after>class Array
  def average
    reduce(:+).to_f / size.to_f
  end

  def self.restore_avg(avg, count, delta=0.5, precision=2)
    res = []
    count.times do |t|
      res << (Random.rand(avg-delta...avg+delta)).round(3)
    end
    if res.average != avg
      diff = (res.average - avg)    
      res.map! { |el| (el - diff).round(precision) }
    else
      res.map! { |el| el.round(precision) } if precision != 3
    end
    return res
  end

end

{'fraction_non_alphanumeric': 0.14416243654822336, 'fraction_numerical': 0.01116751269035533, 'mean_word_length': 2.2649006622516556, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '6209297', 'n_tokens_mistral': 370, 'n_tokens_neox': 356, 'n_words': 89}