#### Archived

This topic is now archived and is closed to further replies.

# root-mean-square

## Recommended Posts

hi,

does anyone know how to write php code for a root mean square, i was brosing on the net and saw it and wanted to know how it was done.

##### Share on other sites
hi,

does anyone know how to write php code for a root mean square, i was brosing on the net and saw it and wanted to know how it was done.
[/quote]I don't fully understand, do you want to know how to calculate the RMS of an array of values?

##### Share on other sites
well i saw on a rating thing, they use a root mean square to combat someone who just keeps putting 1111111111111111111111111111111 for everone...

so i wanted to know how they do it

##### Share on other sites
I don't understand how this will help, RMS "is a statistical measure of the magnitude of a varying quantity". I'm not brilliant in maths, but I think this is how you work out the RMS of an array of values:
[code]<?php
function rms() {
\$vals = func_get_args();
\$new = "";
foreach(\$vals as \$n) \$new += pow(\$n,2);
\$new = sqrt(\$new / count(\$vals));
echo \$new;
}
?>[/code]
Someone that [i]is[/i] good at maths, please do go ahead and correct me if I'm wrong.

##### Share on other sites
ok.. ill try.. so in a rating system wat would you use, just a normal average?

##### Share on other sites
ok.. ill try.. so in a rating system wat would you use, just a normal average?
[/quote]Personally, yes. Maybe you could filter out all ratings that are full of 1's...