Re: which is faster?

new topic     » goto parent     » topic index » view thread      » older message » newer message

this is what I want to optimise:

global function st_dev(sequence s, atom X)
    atom m, sum, sd
    integer l
    sum = 0
    l = length(s)
    m = mean(s)
    s -= m
    for i = 1 to length(s) do 
	sum += power(s[i], 2)
    end for
    sd = sqrt(sum/(length(s)-1))
    if X = 0 then
	return sd
    else -- return the z-score
	return (X - m)/sd
    end if
end function


can this be improved?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu