Skip to content

Commit

Permalink
Merge pull request #2 from tochnonement/master
Browse files Browse the repository at this point in the history
Mode function
  • Loading branch information
rgertenbach authored Dec 28, 2020
2 parents 5a2a1e4 + cf908b5 commit 8331128
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,22 @@ local function quartile(t, i)
else
return quantile(t, quartiles[i])
end
end
end

local function mode(t)
local frequencies = frequency(t)
local last
local most

for value, repeats in pairs(frequency) do
if not last or (value > last) then
last = repeats
most = value
end
end

return most
end


--[[ Normal Distribution Functions ]]--
Expand Down

0 comments on commit 8331128

Please sign in to comment.