• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1426
  • Last Modified:

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()
0
saini_er
Asked:
saini_er
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
Aleksandar BradarićSoftware DeveloperCommented:
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
0
 
Frosty555Commented:
Look into the STD(), or  STDDEV_POP() aggregate functions in mysql.

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_std
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
saini_erAuthor Commented:
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
0
 
UmeshMySQL Principle Technical Support EngineerCommented:
0
 
Frosty555Commented:
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;
0
 
Frosty555Commented:
"You can nest the aggregate functions in MySQL"

Sorry, you CAN'T nest the aggregate functions in MySQL.
0
 
saini_erAuthor Commented:
I don't  think there is any direct fuction . so I am going by mathematic expression and calculate result out of it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now