JSThePatriot Posted March 2, 2009 Posted March 2, 2009 @Everyone I believe we will most likely have these functions included in the Math.au3 UDF. I have all mine prefaced with _Stats_FunctionName(). Here's what I have done so far...not as pretty as what you two have put together. expandcollapse popupFunc _Stats_StandardDeviation(ByRef $a_Numbers, $i_Resolution = 5) EndFunc Func _Stats_EstimatedDeviation() EndFunc Func _Stats_Mean(ByRef $a_Numbers, $i_MeanType = 1) If Not IsArray($a_Numbers) Then SetError(1, 0, "") ;If not an array of value(s) then error and return a blank string If Not IsInt($i_MeanType) Then SetError(2, 0, "") ;MeanType isn't an integer If $i_MeanType < 1 Then SetError(3, 0, "") ;Incorrect MeanType Local $i_Count = _Stats_Count($a_Numbers) Local $n_Sum = _Stats_Sum($a_Numbers) Local $n_Mean Switch $i_MeanType Case 1 ;Arithmetic Mean Return $n_Mean = ($n_Sum / $i_Count) Case 2 Case 3 Case 4 Case 5 EndSwitch EndFunc Func _Stats_Sum(ByRef $a_Numbers) If Not IsArray($a_Numbers) Then SetError(1, 0, "") ;If not an array of value(s) then error and return a blank string Local $i_Count = _Stats_Count($a_Numbers) Local $n_SumX = 0 For $i = 0 To $i_Count - 1 Step 1 $n_Sum += $a_Numbers[$i] Next Return $n_Sum EndFunc Func _Stats_Count(ByRef $a_Numbers) Return UBound($a_Numbers) EndFunc Func _Stats_Average(ByRef $a_Numbers) Return _Stats_Mean($a_Numbers, 1) EndFunc Let me know what you think... Jarvis AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Ealric Posted March 2, 2009 Author Posted March 2, 2009 I'll have some changes posted shortly. Thanks both. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]
Ealric Posted March 2, 2009 Author Posted March 2, 2009 Okay, Andy and JS - please look over the include I posted. I'm using Andy's mean in my program to calculate the mean and using my STD to calculate the standard deviation. The STD function I was using uses a secondary method for calculation (there are multiples) so it did not have to use a direct mean function of any sort. I just used a mean to represent that value in my program. Please look it over and let me know what you think. @ JS, I think you should shorten your function names to one underscore and name them something similar: _Sum or _StatsSum etc. etc. I have no problems having them in the Math.au3 file. That would be an appropriate spot since there aren't many functions in there. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]
Ealric Posted March 2, 2009 Author Posted March 2, 2009 By the way, adding another post here.I will in no way, shape, or form take offense at "anyone" that wishes to make any function that I write better from a coding standpoint. It's important to me to use whichever code is fastest, cleanest and shortest. @JS and @AndyIf either of you find a way to use any of your functions inside my StdDev function that meets the above criteria, definitely let me know and provide a solution. Again, I will never take offense at that ever. It took me awhile, but I found a website that actually houses the standard deviation formula I'm using:http://www.easycalculation.com/statistics/...d-deviation.phpLook down at Standard Deviation Method #2. That describes my Std in a nutshell. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]
JSThePatriot Posted March 2, 2009 Posted March 2, 2009 Okay, Andy and JS - please look over the include I posted.I'm using Andy's mean in my program to calculate the mean and using my STD to calculate the standard deviation. The STD function I was using uses a secondary method for calculation (there are multiples) so it did not have to use a direct mean function of any sort. I just used a mean to represent that value in my program. Please look it over and let me know what you think.@ JS,I think you should shorten your function names to one underscore and name them something similar:_Sum or _StatsSumetc. etc.I have no problems having them in the Math.au3 file. That would be an appropriate spot since there aren't many functions in there.I'll check the posted include shortly.The reason I went with the _Stats_FunctionName is due to my bad memory. I thought there was usually an extra _ in there. I am fine with _StatsFunctionName.Thanks,Jarvis AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
JSThePatriot Posted March 2, 2009 Posted March 2, 2009 (edited) @Everyone What do you think of offering the different methods for calculating the deviations? There are mutliple methods for StdDev, and I believe only one I have really seen for EstDev. Just like Andy's mean calculation...There are more on Wikipedia that I was going to add which is why my Switch statement is empty. I added the _StatsAverage() due to compatibility of terms. A lot of people will know the "Mean" as the Arithmetic Average. Should we include all the available methods from Wikipedia, or just the one's Andy has already included? I know more about Statistic functions in SPC applications than other methods so that's where my knowledge will mostly come into play. expandcollapse popupFunc _StatsStandardDeviation() _StatsStdDev() EndFunc Func _StatsEstimatedDeviation() _StatsEstDev() EndFunc Func _StatsMean(ByRef $a_Numbers, $i_MeanType = 1) If Not IsArray($a_Numbers) Then SetError(1, 0, "") ;If not an array of value(s) then error and return a blank string If Not IsInt($i_MeanType) Then SetError(2, 0, "") ;MeanType isn't an integer If $i_MeanType < 1 Then SetError(3, 0, "") ;Incorrect MeanType Local $i_Count = _StatsCount($a_Numbers) Local $n_Sum = _StatsSum($a_Numbers) Local $n_Mean Switch $i_MeanType Case 1 ;Arithmetic Mean Return $n_Mean = ($n_Sum / $i_Count) Case 2 Case 3 Case 4 Case 5 EndSwitch EndFunc Func _StatsSum(ByRef $a_Numbers) If Not IsArray($a_Numbers) Then SetError(1, 0, "") ;If not an array of value(s) then error and return a blank string Local $i_Count = _StatsCount($a_Numbers) Local $n_SumX = 0 For $i = 0 To $i_Count - 1 Step 1 $n_Sum += $a_Numbers[$i] Next Return $n_Sum EndFunc Func _StatsCount(ByRef $a_Numbers) Return UBound($a_Numbers) EndFunc Func _StatsAverage(ByRef $a_Numbers) Return _StatsMean($a_Numbers, 1) EndFunc Func _StatsCp($n_USL, $n_LSL, $n_StdDev) If Not IsNumber($n_USL) Then SetError(1, 0, "") If Not IsNumber($n_LSL) Then SetError(2, 0, "") If Not IsNumber($n_StdDev) Then SetError(3, 0, "") Return ($n_USL - $n_LSL) / (6 * $n_StdDev) EndFunc Func _StatsCpk($n_USL, $n_LSL, $n_StdDev, $n_Mean) If Not IsNumber($n_USL) Then SetError(1, 0, "") If Not IsNumber($n_LSL) Then SetError(2, 0, "") If Not IsNumber($n_StdDev) Then SetError(3, 0, "") If Not IsNumber($n_Mean) Then SetError(4, 0, "") Local $n_AboveMean = ($n_USL - $n_Mean) / (3 * $n_StdDev) Local $n_BelowMean = ($n_Mean - $n_LSL) / (3 * $n_StdDev) If $n_AboveMean < $n_BelowMean Then Return $n_AboveMean Else Return $n_BelowMean EndIf EndFunc Func _StatsCr() EndFunc Func _StatsPp() EndFunc Func _StatsPpk() EndFunc Func _StatsPr() EndFunc Edit01: Finished fixing the code to remove _'s Regards, Jarvis Edited March 2, 2009 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
Ealric Posted March 2, 2009 Author Posted March 2, 2009 I agree JS. There are multiple ways of returning Standard Deviation. One of the ways can be used to include some of the functions you both have worked out. I think there should be multiple "cases" for each function that can be used differently to allow anyone the ability to calculate using those functions in the way that they want to. I'll begin work on adjusting StdDev for use with the two types of standard deviation returns. The next case will include Andy's _Mean, and possibly a few of your functions if they are required. Good work mate. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]
Ealric Posted March 2, 2009 Author Posted March 2, 2009 I've updated the _StdDev UDF to include two types of returns - standard / non-standard. See the first topic post for more information. The standard return is the one that uses means (default) - the non-standard way uses squares. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now