- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
Difference between revisions of "Module:Stat"
Jump to navigation
Jump to search
(does this work?) |
|||
Line 10: | Line 10: | ||
return string.format("%." .. f .. "f", 100 * (1 - (1 - a / b) ^ n)) | return string.format("%." .. f .. "f", 100 * (1 - (1 - a / b) ^ n)) | ||
else | else | ||
− | return " | + | return "nil" |
end | end | ||
end | end | ||
Line 21: | Line 21: | ||
return string.format("%.f", math.log(1 - q / 100) / math.log(1 - a / b)) | return string.format("%.f", math.log(1 - q / 100) / math.log(1 - a / b)) | ||
else | else | ||
− | return " | + | return "nil" |
end | end | ||
+ | end | ||
+ | |||
+ | function Stat.error_(a, b, pc) | ||
+ | pc = pc or 1.96 | ||
+ | local p = a / b | ||
+ | local se = math.sqrt(p * (1 - p) / b) | ||
+ | return 100 * (pc * se + 0.5 / b) | ||
end | end | ||
Line 31: | Line 38: | ||
local pc = frame.args["percentile"] and tonumber(frame.args["percentile"]) or 1.96 | local pc = frame.args["percentile"] and tonumber(frame.args["percentile"]) or 1.96 | ||
if a and b and f and pc then | if a and b and f and pc then | ||
− | + | return string.format("%." .. f .. "f", Stat.error_(a, b, pc)) | |
− | |||
− | return string.format("%." .. f .. "f", | ||
else | else | ||
− | return " | + | return "nil" |
end | end | ||
end | end | ||
Line 46: | Line 51: | ||
return string.format("%.f", ( 1 / ( ( 1 - ( a / b ) ) ^ ( sh ) ) ) ) | return string.format("%.f", ( 1 / ( ( 1 - ( a / b ) ) ^ ( sh ) ) ) ) | ||
else | else | ||
− | return " | + | return "nil" |
end | end | ||
end | end | ||
return Stat | return Stat |
Revision as of 18:58, 9 November 2017
Documentation for this module may be created at Module:Stat/doc
local Stat = {}
function Stat.rate(frame)
local a = tonumber(frame.args[1])
local b = tonumber(frame.args[2])
local n = frame.args[3] and tonumber(frame.args[3]) or 1
local f = frame.args["format"] and tonumber(frame.args["format"]) or 2
if a and b and n and f then
return string.format("%." .. f .. "f", 100 * (1 - (1 - a / b) ^ n))
else
return "nil"
end
end
function Stat.trials(frame)
local a = tonumber(frame.args[1])
local b = tonumber(frame.args[2])
local q = tonumber(frame.args[3])
if a and b and q then
return string.format("%.f", math.log(1 - q / 100) / math.log(1 - a / b))
else
return "nil"
end
end
function Stat.error_(a, b, pc)
pc = pc or 1.96
local p = a / b
local se = math.sqrt(p * (1 - p) / b)
return 100 * (pc * se + 0.5 / b)
end
function Stat.error(frame)
local a = tonumber(frame.args[1])
local b = tonumber(frame.args[2])
local f = frame.args["format"] and tonumber(frame.args["format"]) or 2
local pc = frame.args["percentile"] and tonumber(frame.args["percentile"]) or 1.96
if a and b and f and pc then
return string.format("%." .. f .. "f", Stat.error_(a, b, pc))
else
return "nil"
end
end
function Stat.players(frame)
local a = tonumber(frame.args[1])
local b = tonumber(frame.args[2])
local sh = tonumber(frame.args[3])
if a and b and sh then
return string.format("%.f", ( 1 / ( ( 1 - ( a / b ) ) ^ ( sh ) ) ) )
else
return "nil"
end
end
return Stat