Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SIGMA = function(t)
- local sum = 0
- for i = 1, #t do
- sum = sum + t[i]
- end
- return sum
- end
- local MEANS = function(t)
- local sigma = {xini = 0, ni = SIGMA(t[1])}
- local p_xini = {}
- for i = 1, #t[1] do
- p_xini[i] = t[1][i]*t[2][i]
- end
- sigma.xini = SIGMA(p_xini)
- return(sigma.xini/sigma.ni)
- end
- local VARIANCE = function(t)
- local sigma = {ni = SIGMA(t[1]), nixix2 = 0}
- local means_t = MEANS(t)
- local p_nixix2 = {}
- for i = 1, #t[1] do
- p_nixix2[i] = t[1][i]*(t[2][i]-means_t)^2
- end
- sigma.nixix2 = SIGMA(p_nixix2)
- return(sigma.nixix2/sigma.ni)
- end
- local STANDARD_DEVIATION = function(v)
- return math.sqrt(v)
- end
- local MEDIAN = function(t)
- local n = #t[1]
- return((n % 2 == 0) and t[2][(n/2)+1] or t[2][(n+1)/2])
- end
- --! en cours
- local QUARTILES = function(t)
- local q = {0, MEDIAN(t), 0}
- return unpack(q)
- end
- local serie = {
- {4, 20, 43, 100, 200, 250, 190, 113, 50, 19, 6, 5}, -- ni
- {8, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9, 9.1} -- xi
- }
- print("sommes des lignes du tableau : " .. SIGMA(serie[1]) .. " " .. SIGMA(serie[2]))
- print("moyenne : " .. MEANS(serie), "\nvariance : " .. VARIANCE(serie), "\necart type : " .. STANDARD_DEVIATION(VARIANCE(serie)))
- print("mediane : " .. MEDIAN(serie))
- print("quartiles : ", QUARTILES(serie))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement