dbTalk Databases Forums  

standard deviation

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss standard deviation in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dan
 
Posts: n/a

Default standard deviation - 12-15-2005 , 01:51 PM






Does anyone know how to calculate a standard deviation measure using the
mean of another population(parent dimension set)?

Example:
Facility 'XYZ' has 5 patients (base table in sql server database) with the
following ages in years: (10,20,30,40,50)
Using standard deviation logic, "SQRT( (Sum(x-u)^2) / Count)", where u = 30
(the average of the 5 patients in the set) we get Stddev=14.14
But I would like to use the average age of the patients in the facilities
parent dimension level which is u = 50 giving me Stddev = 24.49.

I have successfully implemented the following, but this uses the set
average and NOT the parent average:
1) load in a simple SUM measure (x)
2) load in a simple SUM measure of x squared (x2)
3) load in a counter measure called cnt.
4) Then using the formula for stdev, create a measure in the cube as
follows: ((x2 - ((x^2)/cnt))/cnt)^0.5

I am using AS 2000 which works off a sql server 2000 database.

Thanks,

_________________________

Daniel J. Zaccarine
Hanford Bay Associates, Ltd.
dan_zaccarine (AT) hanfordbay (DOT) com
http://www.hanfordbay.com
___________________________



Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: standard deviation - 12-15-2005 , 08:37 PM






Assuming a [Facilities] dimension, here's an approach using some
intermediate calculated measures:

Quote:
Member [Measures].[avgx] as
'[Measures].[x]/[Measures].[cnt]'

Member [Measures].[avgp] as
'([Measures].[avgx], [Facilities].Parent)'

Member [Measures].[varx] as
'([Measures].[x2] / [Measures].[cnt])
- ([Measures].[avgp] * ((2 *
[Measures].[avgx]) - [Measures].[avgp]))'

Member [Measures].[sigx] as
'[Measures].[varx] ^ 0.5'
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #3  
Old   
Dan
 
Posts: n/a

Default Re: standard deviation - 12-16-2005 , 03:06 PM



Deepak,

Your algorithm worked perfectly.

Thank YOU!!!
Dan
___________________________

Daniel J. Zaccarine
Hanford Bay Associates, Ltd.

http://www.hanfordbay.com
___________________________
"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
Assuming a [Facilities] dimension, here's an approach using some
intermediate calculated measures:


Member [Measures].[avgx] as
'[Measures].[x]/[Measures].[cnt]'

Member [Measures].[avgp] as
'([Measures].[avgx], [Facilities].Parent)'

Member [Measures].[varx] as
'([Measures].[x2] / [Measures].[cnt])
- ([Measures].[avgp] * ((2 *
[Measures].[avgx]) - [Measures].[avgp]))'

Member [Measures].[sigx] as
'[Measures].[varx] ^ 0.5'



- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.