# Calculate the Quadratic Mean

Page 1 of 1

## 0 Replies - 1874 Views - Last Post: 09 April 2012 - 07:20 AM

### #1 Ryano121

• D.I.C Lover

Reputation: 1461
• Posts: 3,289
• Joined: 30-January 11

# Calculate the Quadratic Mean

Posted 09 April 2012 - 07:20 AM

Description: See Example Usage in snippetThe quadratic mean is a statistical measure of the magnitude of a varying quantity. It is especially useful when variates are positive and negative.
```public class Means
{
// Returns the quadratic mean (or Root Mean Square) of a data set
public static double quadraticMean(double[] data)
{
double sum = 0;

for(int i = 0; i < data.length; i++)
{
sum += Math.pow(data[i], 2);
}

return Math.sqrt(sum / data.length);
}

public static void main(String[] args)
{
double[] x = { 2, 3, 4, 5, 6, 8, 10, 11.53542 };

System.out.println("Quadratic Mean = " + Means.quadraticMean(x));
}
}

// OUTPUT

// Quadratic Mean = 6.955806159033617
```

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }