It seems like this would work for you:
arr = [1,3,5,3,6,1,4,6,7,6,6,6,6,6]
arr.group_by(&:itself).transform_values{|v| arr.size / v.size}.flat_map do |k,v|
[k] * v
end.sample
We group the elements and count them then we create a new Array
with the number of elements inverted to favor the lesser occurrences. e.g.
arr.group_by(&:itself).transform_values{|v| arr.size / v.size}.flat_map do |k,v|
[k] * v
end.group_by(&:itself).transform_values(&:size)
#=> {1=>7, 3=>7, 5=>14, 6=>2, 4=>14, 7=>14}
Since 5 occurred once originally it now occurs 14 times (same with 4 and 7).
So 5,4, and 7 have equal likelihood of being chosen and are each twice as likely as 1 and 3 which occured twice and 7 times as likely as 6.
Also maybe something like this might be more efficient
grouping =arr.group_by(&:itself).transform_values(&:size).
scale = grouping.values.uniq.reduce(&:lcm)
grouping.flat_map do |k, v|
[k] * (scale / v)
end.sample