This alias returns the standard deviation for a set of numbers.
Useage: $standev(1,2,3,4,etc.)
alias standev {
var %total = $numtok($1-,32), %average = $calc(($replace($1-,$chr(32),$chr(43))) / %total), %x = 1, %numbtotal = 0
while (%x <= %total) {
if ($gettok($1-,%x,32) !isnum) { echo 2 -a * Invalid parameters: $chr(36) $+ standev | halt }
var %numb = $calc(($gettok($1-,%x,32) - %average) ^ 2)
inc %numbtotal %numb
inc %x
}
return $round($sqrt($calc(%numbtotal / %total)),2)
}
That\'s because, the commas will be replaced by spaces inside the alias. Put an \'echo -a $1-\' on the 2nd line of the alias to see what I mean.
Why use commas? When you separate anything with a comma in the alias like the sample usage, mIRC treats each separated token as a parameter meaning the first token will be $1, 2nd will be $2 and so on, kinda like what /tokenize does.
Sample:
//echo -a $standev(1,2,3,4,5)
and it should give you the same numbers separated by a space.
See the difference?