--[[
getMean(t)
Returns the mean of a table of numbers.
@param t The table of numbers.
@return The mean of the table.
]]
function getMean(t)
local sum = 0
local count = 0
for k, v in pairs(t) do
if type(v) == 'number' then
sum = sum + v
count = count + 1
end
end
--[[
getMode(t)
Returns the mode of a table of numbers.
@param t The table of numbers.
@return The mode of the table.
]]
return (sum / count)
end
function getMode(t)
local counts = {}
local maxCount = 0
for k, v in pairs(t) do
counts[v] = (counts[v] or 0) + 1
if counts[v] > maxCount then
maxCount = counts[v]
end
end
local mode = {}
for k, v in pairs(counts) do
if v == maxCount then
table.insert(mode, k)
end
end
--[[
getRange(t)
Returns the range of a table of numbers.
@param t The table of numbers.
@return The range of the table.
]]
return mode
end
function getRange(t)
local min = math.huge
local max = -math.huge
for k, v in pairs(t) do
if v < min then
min = v
end
if v > max then
max = v
end
end
return max - min
--[[
getMedian(t)
Returns the median of a table of numbers.
@param t The table of numbers.
@return The median of the table.
]]
end
function getMedian(t)
local temp = {}
for k, v in pairs(t) do
table.insert(temp, v)
end
table.sort(temp)
if #temp % 2 == 0 then
return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2
else
return temp[math.ceil(#temp / 2)]
end
end
Shame all these posts and resources I make are getting deleted or hidden. Not like a spend time on them or anything.
This is getting really frustrating. I put a lot of effort into these posts and resources, and it feels like all that work is just being undone. I know that the people who are deleting or hiding my work don’t think that it’s valuable, but it is to me. And I know I’m not the only one who feels this way.
It’s just not fair. We put so much time and effort into something, only to have it be taken away without any explanation. I know that the people who are doing this think they’re helping, but they’re not. All they’re doing is making it harder for the rest of us.
We need to find a way to stop this from happening. Maybe we can create a petition or something, to get the attention of the people who are doing this. I’m not sure what the solution is, but something needs to be done. Otherwise, all of our hard work will just keep getting deleted or hidden.
So please, if you agree with me, spread the word. Let’s try to put a stop to this. We deserve to be heard.
I agree with you here and disagree with the moderators who are taking them down, these posts you are making can help many people with formulas on how to find the mean, average and it will teach them actual math which they can use when they go to school, this is the thing with coding, it teaches you stuff mathematically which you can use in real life and at school aswell, I don’t think some people realise that