Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > MySQL STD() funny results?...

MySQL STD() funny results?...
Thread Tools
Registered User
Join Date: Sep 2002
Location: New York City
Status: Offline
Reply With Quote
May 18, 2004, 03:58 AM
 
Hi all.

I'm trying to calculate the Standard Deviation for some data in my db. Everything executes, but I get funny results. The MySQL results are different from the results that Microsoft Excel give me. When I performed the calculations by hand I got results that matched Excel...so this makes me wonder why MySQL is giving me incorrect numbers. The Average (mean) functions of MySQL and Excel give matching results, but the STD functions differ. (note: I get the same results for "STD" and "STDDEV"..thought I'd try both, even though some documents seemed to make them sound the same)

Any help would be greatly appreciated.

Thanks.

-Ben


Here is the table with the data:

CREATE TABLE `stats_test` (
`id` int(11) NOT NULL auto_increment,
`x_value` int(11) default NULL,
`y_value` int(11) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=9 ;

INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (1, 5, 2);
INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (2, 1, 4);
INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (3, 4, 6);
INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (4, 3, 5);
INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (5, 5, 7);
INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (6, 4, 3);
INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (7, 5, 1);
INSERT INTO `stats_test` (`id`, `x_value`, `y_value`) VALUES (8, 7, 9);

Here's the SQL query:
select AVG(x_value) x_avg, STD(x_value) x_std, AVG(y_value) y_avg, STD(y_value) y_std from stats_test

Here's what I get from MySQL:
x avg. 4.25
y avg. 4.625
x std. dev. 1.6394
y std. dev. 2.4969

Here's what I get from Excel:
x avg. 4.25
y avg. 4.625
x std. dev. 1.75
y std. dev. 2.67
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:31 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2