Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
Hi,
Can anybody help me with the Stdev function. I can't get it to work.
Simple case with question asked how many travels (0, 1, 2 or 3) a year a family undertakes. 200 families answered:
Travels, Families
0, 50
1, 80
2, 60
3, 10
Stdev(Aggr(Sum(Travels), Families)) gives me 1.29. It should be approx. 0.85.
Any help?, Zach
 
					
				
		
.png) hic
		
			hic
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		If you load the data using the following script, you will recreate the raw data and the stdev (and average and all other statistical entities) will be calculated correctly:
Data:
Load * while iterno()<= Families;
Load * inline
[Travels, Families
0, 50
1, 80
2, 60
3, 10];
HIC
 
					
				
		
.png) hic
		
			hic
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		But why do you use the Aggr function? This creates a nested aggregation and you need only a single aggregation. The expression "stdev(Travels)" will give 0.85 as answer.
HIC
 
					
				
		
Hi, thanks for your reply. If I use stdev(Travels) i still get the 1.29?
 
					
				
		
.png) hic
		
			hic
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		If you have the raw data, i.e all 200 records, then stdev will work the way you expect it. But if you calculate it from a table of just four records (the ones in your initial post), then 1.29 is correct.
You can most likely calculate it indirectly from you four records using a formula with weighted values (you need to weight the "travels" number by number of families).
HIC
 
					
				
		
.png) hic
		
			hic
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		If you load the data using the following script, you will recreate the raw data and the stdev (and average and all other statistical entities) will be calculated correctly:
Data:
Load * while iterno()<= Families;
Load * inline
[Travels, Families
0, 50
1, 80
2, 60
3, 10];
HIC
 
					
				
		
Hi Henric,
Very helpfull. I thought that the Stdev function would 'automatically' expand over the two elements. Good to know that I need all the individual records for Stdev to work the way I want it to. I now understand that the 1.29 simply is the standard deviation of 0, 1, 2 and 3 occuring 1 time each.
Thank you.
 
					
				
		
 did
		
			did
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Dear HIC,
your approach means that stdev operates correctly only with raw data.
In this very case there should be as many rows as count(Families), i.e. = 200.
What about % numbers? What if my table looks like this:
[Travels, Families
0, 25%
1, 40%
2, 30%
3, 5%];
How many rows my raw table must have?
 
					
				
		
.png) hic
		
			hic
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		