Jump to content

root-mean-square


brown2005

Recommended Posts

[quote author=brown2005 link=topic=102059.msg404505#msg404505 date=1154002874]
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?
Link to comment
https://forums.phpfreaks.com/topic/15799-root-mean-square/#findComment-64615
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.
Link to comment
https://forums.phpfreaks.com/topic/15799-root-mean-square/#findComment-64623
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.