<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Sample Standard Deviation (and SQL)</title>
	<link>http://blog.todmeansfox.com/2006/12/12/sample-standard-deviation-and-sql/</link>
	<description>Business Intelligence, Data Warehousing, SQL, Visual FoxPro.</description>
	<pubDate>Thu, 20 Nov 2008 22:50:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: Anders Altberg</title>
		<link>http://blog.todmeansfox.com/2006/12/12/sample-standard-deviation-and-sql/#comment-653</link>
		<author>Anders Altberg</author>
		<pubDate>Sat, 05 Jan 2008 19:32:18 +0000</pubDate>
		<guid>http://blog.todmeansfox.com/2006/12/12/sample-standard-deviation-and-sql/#comment-653</guid>
		<description>Hi Todd, 
The Std (standard deviation) function can be done entirely in VFP SQL. 
Can be combined with GROUP BY which can save a lot of code. 
Assumin a numerical column 'score' in a table 'Scores':
SELECT  SQRT(AVG(score^2)-AVG(score)^2) FROM Scores
A Samples STD can also be calculated: 
 SELECT SQRT(COUNT(*)*(AVG(score^2)-AVG(score)^2)/(COUNT(*)-1+0.000001)) FROM Scrores  
or a Variance
SELECT  COUNT(*)*(AVG(score^2)-AVG(score)^2)/(COUNT(*)-1+0.000001) FROM Scores

The +0.000001 getsa around a possible divide by zero error. 

Cheers
Anders 

Anders Altberg
Pragam</description>
		<content:encoded><![CDATA[<p>Hi Todd,<br />
The Std (standard deviation) function can be done entirely in VFP SQL.<br />
Can be combined with GROUP BY which can save a lot of code.<br />
Assumin a numerical column &#8217;score&#8217; in a table &#8216;Scores&#8217;:<br />
SELECT  SQRT(AVG(score^2)-AVG(score)^2) FROM Scores<br />
A Samples STD can also be calculated:<br />
 SELECT SQRT(COUNT(*)*(AVG(score^2)-AVG(score)^2)/(COUNT(*)-1+0.000001)) FROM Scrores<br />
or a Variance<br />
SELECT  COUNT(*)*(AVG(score^2)-AVG(score)^2)/(COUNT(*)-1+0.000001) FROM Scores</p>
<p>The +0.000001 getsa around a possible divide by zero error. </p>
<p>Cheers<br />
Anders </p>
<p>Anders Altberg<br />
Pragam</p>
]]></content:encoded>
	</item>
</channel>
</rss>
