![]() |
That's not mean deviation-that's CRUEL deviation!
^:sign_yeah::agree:http://www.mathsisfun.com/data/image...ion-sample.gif I see it so clearly now; Jeff! You've got it in a nutshell!:k_confused:I didn't know air guns were so complicated.:timeout:
|
Err you don't really need to create an object (class) for this, a simple function should do just fine.
|
Yep. A new function is plenty good enuff. I don't like adding some monster package I'll never use.
|
Nothing worse than having a monster package and never using it.
|
I have never understood why it has to divide by N-1. Can anyone explain why it is less 1?
I mean, simple averages are simply the sum divided by N. That makes sense to spread the (sum of) differences accross all samples. |
Quote:
http://i298.photobucket.com/albums/m...drums-K5UJ.gif |
You know, when I saw the title of this thread, I was a bit confused. I live in Hollywood, California; here, a standard deviation is anything that does not require above normal medical attention, a lengthy session in a confessional, or an excessive bail...
<O> |
I am a bit rusty on my C++, but maybe we can get you going in the right direction with some psuedo-code!
We know we will have a list of items with numeric values, for simplicity sake, let's assume these are doubles. So, let's pass that to stubbed method: Code:
public void CalculateStandardDev(double listOfDoubles) Code:
listOfDoubles.size(); Code:
public void CalculateStandardDev(double listOfDoubles) Code:
public void CalculateStandardDev(double listOfDoubles) |
Sorry, was scared I was going to lose progress.. Anyways, now we have the sum of all of our items and our 'n' variable. But we still don't have the mean, or the average. So.. to find the average we divide the sum of all of our numbers by 'n', our size of our list:
Code:
public void CalculateStandardDev(double listOfDoubles) :up: Done with Step 1! So now we go into Step 2, which has this equation: http://www.mathsisfun.com/data/image...tion-part1.gif We look at each value and subtract the mean and square the result. Sounds easy enough: Code:
public void CalculateStandardDev(double listOfDoubles) Code:
pow(number, exponentValue) Code:
public void CalculateStandardDev(double listOfDoubles) |
Now that we have our variance, the last step is extremely easy. We simply take the square root of variance to give us the Standard Deviation value!!!
Code:
public double CalculateStandardDev(double listOfDoubles) |
Brrr, take it away, it hurts our eyes! Last time I did stuff like that, was in GFA 3.0 on an Amiga, 25 years ago. :D
|
I'm gonna go with C++ Mathematical Expression Toolkit Library (ExprTk).
It's a neat header file I can use then throw away along with those old Dewalt side cuts. :D |
Quote:
|
I had a deviated septum once.
|
Quote:
|
All times are GMT -5. The time now is 11:47 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.