By Olliegod on Jun 13, 2007

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)


Sign in to comment.
guest598594   -  Sep 24, 2007

this could of been really helpful if i knew about it like a week ago when i needed to do stdev by hand :D

Olliegod   -  Jun 14, 2007

What xDaeMoN said.

xDaeMoN   -  Jun 13, 2007

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.


  1. If you still have the echo there, leave it.
  2. then do
//echo -a $standev(1,2,3,4,5)

and it should give you the same numbers separated by a space.

  1. then now change $1- to $1 in echo inside the alias
  2. now do the same echo again in #2 & it would only give you \"1\"
  3. Now use the same echo BUT change the comma to a space & it should give you all the numbers.

See the difference?

RusselB   -  Jun 13, 2007

In your usage, you show using commas to separate the parameters, yet in your code, you check for space separation.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.