saini_er
asked on
How can I take standard deviation in MYsql?
I have two columns containing two different timestamps for particular user. How can I calculate Standard deviation for this.
Is there any direct function available to perform this like sum() or avg()
Is there any direct function available to perform this like sum() or avg()
You have the STDDEV() function... Not sure if that's what you need: http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html#function_stddev
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys for reply.....All of these methods are for finding standard deviation population where one value is randomly picked from table and then used as average..
I s there any function which can give regualr standard deviation whch is generally found by calculating exact mean
I s there any function which can give regualr standard deviation whch is generally found by calculating exact mean
mysql supports STD() which is population standard deviation, and STDDEV_SAMP() which returns the sample standard deviation. Not sure but maybe the sample deviation is what you're looking for.
Alternatively you can do it manually using some variables. You can nest the aggregate functions in MySQL But I think if you get the average first and store it in a variable, you can do the rest. E.g. something like:
SELECT @ln_average := AVG(total) FROM yourtable;
SELECT (1/COUNT(total)) * SUM( POW(total - @ln_average,2) ) FROM yourtable;
Alternatively you can do it manually using some variables. You can nest the aggregate functions in MySQL But I think if you get the average first and store it in a variable, you can do the rest. E.g. something like:
SELECT @ln_average := AVG(total) FROM yourtable;
SELECT (1/COUNT(total)) * SUM( POW(total - @ln_average,2) ) FROM yourtable;
"You can nest the aggregate functions in MySQL"
Sorry, you CAN'T nest the aggregate functions in MySQL.
Sorry, you CAN'T nest the aggregate functions in MySQL.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.