Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.