# Find the average, median, mode, and range

It's easier to put this into coding terminology, so here we go:

1. First find the average, median, mode, and range.
2. Then, put those values in another array, then find the new average, median, mode, and range.
3. Bonus -10 bytes (yeah, negative bytes, because there's already answers) for programs that can handle this many times (repeat the first steps N times with an extra parameter)
4. Then average those numbers. If there are multiple medians or modes, simply average them!

## Test cases:

[1, 2, 3, 4, 5] -> 2.5625
[1, 1, 1, 1, 1] -> 0.9375
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] -> 48.5
[0, 5, 10, 50] -> 24.375
[4, 4, 8, 10, 16, 24, 100, 150, 200, 200, 250] -> 136.7045454545454545454545454545... (it's fine if there's floating-point inaccuracies)


As this is , the shortest code in bytes wins!

• Specifically for mode, how should we handle arrays where there are two most-common values (e.g., [1, 2, 2, 3, 4, 4])? Is that a situation we need to deal with or can we assume that won't come up? Mar 1 at 0:02
• @cocomac Thanks, fixed it! Mar 1 at 0:05
• In my opinion, this is a boring challenge. It is a mishmash of existing challenges, and the way it is mixed is boring and uncreative. Explaining the downvote. Mar 1 at 0:31
• Related to Seggan's comment: codegolf.meta.stackexchange.com/a/20905/36398. Regarding bonus: codegolf.meta.stackexchange.com/a/8106/36398 Mar 1 at 10:30

# Vyxal, 28 - 10 = 18 bytes

(λṁn∆ṁwfṁnDvOÞMİṁn₌Gg-WW;†)ṁ


Try it Online!

A horrible mess of ns, ṁs and other letters.

## Explained

(λṁn∆ṁwfṁnDvOÞMİṁn₌Gg-WW;†)ṁ
(                         )  # first inputh times
λ                      ;†   # do to argument n:
ṁ                          #  mean of n
n∆ṁwfṁ                    #  average of medians of n
nDvOÞMİṁ            #  average of modes of n. If it was smallest mode or first mode, this could just be ∆M
₌Gg-        #  range of n
WW      #  wrap into a list
ṁ # average of that


# 05AB1E, score: 14 (24 bytes - 10 bonus)

ƒD©Åm®Ð¢ZQÏ®Zsß-)ε¸˜ÅA]н


First input is $$\n\$$, second is the list.

Explanation:

ƒ        # Loop the first (implicit) input + 1 amount of times:
D       #  Duplicate the current list
#  (which will be the second implicit input-list in the first iteration)
©       #  Store it in variable ® (without popping)
Åm     #  Pop and get its mean
®       #  Push list ® again
Ð      #  Triplicate it
¢     #  Pop both copies, and get the count of each value
Z    #  Push the maximum (without popping the list of counts)
Q   #  Check which counts are equal to this maximum
Ï  #  Only keep the values at those truthy values
®       #  Push list ® yet again
Z      #  Push its maximum (without popping the list)
s     #  Swap so the list is at the top of the stack
ß    #  Pop and push its minimum
-   #  Subtract the minimum from the maximum
)       #  Wrap all four items on the stack into a list
ε      #  Map over this quadruplet:
¸     #   Wrap it in a list (for the fourth item; and optionally the mean)
˜    #   Flatten it (in case it was already a list)
ÅA  #   Get the average of this
]        # Close both the map and loop
н       # Pop and push the first item (the average of the extra iteration)
# (after which the result is output implicitly)