Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate STD() vs. Excel STDEV() function
Message
From
02/09/2002 10:11:13
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
02/09/2002 09:56:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00695910
Message ID:
00695940
Views:
18
>>>I don't know a native command. I could probably write you a func... if you ever need it. I was reading somewhere that fox is quite good for developing mathematical functions (amongst other things) etc
>>
>>OK, thanks.
>
>Couldn't resist the challenge...
>
>FUNCTION MyStDev
>LPARAMETERS tcfieldName, tcAlias
>LOCAL lnReccount, lnSum, lnSquare
>LOCAL lcTalk
>
>lcTalk = SET( "TALK")
>SET TALK OFF
>
>lnReccount = RECCOUNT( tcAlias)
>
>CALCULATE SUM( EVALUATE( tcFieldName)) TO lnSum
>
>CALCULATE SUM( EVALUATE( tcFieldName)^2) TO lnSquare
>
>SET TALK &lcTalk
>
>RETURN SQRT((( lnReccount*lnSquare) - ( lnSum^2))/ (lnReccount*(lnReccount-1)))

OK.

Are you aware that you calculate more than one expression in the CALCULATE command? This would probably be slightly faster.

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform