Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Standard Deviation Calculator


  • Please log in to reply
27 replies to this topic

#1 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 15 December 2008 - 03:49 AM

I'm pretty big into statistical analysis and have been working on my own statistical site for college football:

NCAA Stat Pages

So, I like working with Standard Deviation and created a quick calculator. It will give you the number of arguments (numbers) you are comparing, the mean, and the standard deviation up to 5 decimal places.

AutoIt         
#cs =============================================================================== || Program Name:     Standard Deviation Calculator || Description:      Program for sports predictions || Version:          2.0 || Author(s):        Ealric/Drabin =============================================================================== #ce #include <Array.au3> #include <Constants.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <Misc.au3> #include <WinAPI.au3> ; Create our main gui interface ; Define all of our Globals and Arrays Global $author = "Ealric/Drabin", $version = "1.0.0" Global $backgrndcolor = 0x0FFCC66, $commandcolor = 0x066ffff, $optioncolor = 0x0ffdd88, $scriptcolor = 0x0ffddff, $buttoncolor = 0x0660000, $hctrlcolor = 0x000000, $_font = 0x0FFFFFF Global $parent = GUICreate("Standard Deviation Calculator, Version: " & $version, 383, 680) GUISetBkColor($backgrndcolor) ; FILE MENU START ; POSITION -1,0 $filemenu = GUICtrlCreateMenu("File") $filenewitem = GUICtrlCreateMenuItem("New", $filemenu) GUICtrlSetState($filenewitem, $GUI_DEFBUTTON) $fileopenitem = GUICtrlCreateMenuItem("Open", $filemenu) GUICtrlSetState($fileopenitem,  $GUI_DISABLE) GUICtrlCreateMenuItem("", $filemenu, 2) ; $fileitem1 = GUICtrlCreateMenuItem("Test File Item", $filemenu) $fileitem2 = GUICtrlCreateMenuItem("Test File Item 2", $filemenu) GUICtrlCreateMenuItem("", $filemenu, 6) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) ; FILE MENU END ; HELP MENU START ; POSITION -1,3 $helpmenu = GUICtrlCreateMenu("Help", -1, 4) $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu) ; HELP MENU END ; CREATE GUI BUTTONS FOR MACROS ; EACH BUTTON CAN THEN BE REPLACED BY A NEW ONE DEFINED FROM USER INPUT Global $boxonehctrl = _GUICtrlCreateGroupBox("Input", 10, 17, 3, 361, 182) GUICtrlSetColor($boxonehctrl, $hctrlcolor) Global $labelinput = GUICtrlCreateLabel("Enter numbers separated by commas" & @CRLF & "E.g: 10,20,30,40,50",30,35,300,40) Global $inputlabel = GUICtrlCreateInput("", 40, 85, 300, 60) GUICtrlSetBkColor($inputlabel, $_font) Global $calculatebtn = GUICtrlCreateButton("Calculate",140,165,100,20) Global $boxtwohctrl = _GUICtrlCreateGroupBox("Output", 10, 232, 3, 361, 182) GUICtrlSetColor($boxtwohctrl, $hctrlcolor) GUICtrlCreateLabel("Total Numbers:",30,250,100,20) GUICtrlCreateLabel("Mean (Average):",30,270,100,20) GUICtrlCreateLabel("Standard Deviation:",30,290,100,20) Global $numlabel = GUICtrlCreateLabel("",170,250,100,20) Global $meanlabel = GUICtrlCreateLabel("",170,270,100,20) Global $deviatelabel = GUICtrlCreateLabel("",170,290,100,20) GUISetState() #cs Main GUI Script Begins below. #ce While 1     $msg = GUIGetMsg()     Select         Case $msg = $GUI_EVENT_CLOSE Or $msg = $exititem             Exit         Case $msg = $calculatebtn             _arrayfunc()     EndSelect WEnd GUIDelete() #cs Main GUI Script Ends. #ce Func _arrayfunc()     GUICtrlSetData($numlabel,'')     GUICtrlSetData($meanlabel,'')     GUICtrlSetData($deviatelabel,'')     $numarray = StringSplit(GUICtrlRead($inputlabel),",",2)     Local $i,$x,$number,$mean,$deviation     If UBound($numarray) <= 1 Then ; Provide an error on the number of arguments(numbers separated by commas) present.         MsgBox(48,"Error: Number of Arguments","The number of arguments must be greater than one and none of them can be empty.")     Else         $mean = _Mean($numarray)         $number = UBound($numarray)         $deviate = _StdDev($numarray, 5)         GuiCtrlSetdata($numlabel, $number)         GUICtrlSetData($meanlabel, $mean)         GUICtrlSetData($deviatelabel, $deviate)     EndIf EndFunc ; || _GUICtrlCreateEdge() function (by GaryFrost) Func _GUICtrlCreateEdge($i_x, $i_y, $i_width, $i_height, $v_color)     GUICtrlCreateGraphic($i_x, $i_y, $i_width, $i_height, 0x1000)     GUICtrlSetBkColor(-1, $v_color) EndFunc   ;==>_GUICtrlCreateEdge ; || _GUICtrlCreateGroupBox() function (by GaryFrost) ; || Usage _GUICtrlCreateGroupBox(Left, Top, LineWeight, Width, Height, Color) Func _GUICtrlCreateGroupBox($sText, $i_x, $i_y, $i_weight, $i_width, $i_height, $v_color = -1)     Local $hdc = _WinAPI_GetDC(0)     Local $tSize = _WinAPI_GetTextExtentPoint32($hdc, $sText)     If ($v_color == -1) Then $v_color = 0x000000     ; left vertical line     _GUICtrlCreateEdge($i_x, $i_y, $i_weight, $i_height, $v_color)     Local $h_ctlid = GUICtrlCreateLabel($sText, $i_x + 4, $i_y - (DllStructGetData($tSize, "Y") / 2))     GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)     ; top horizontal line     _GUICtrlCreateEdge($i_x + DllStructGetData($tSize, "X") - 4, $i_y, $i_width - DllStructGetData($tSize, "X") + 4, $i_weight, $v_color)     ; right vertical line     _GUICtrlCreateEdge($i_width + $i_x - 1, $i_y, $i_weight, $i_height, $v_color)     ; bottom horizontal line     _GUICtrlCreateEdge($i_x, $i_height + $i_y - 1, $i_width + $i_weight - 1, $i_weight, $v_color)     Return $h_ctlid EndFunc   ;==>_GUICtrlCreateGroupBox #cs INCLUDE IS BELOW #ce #include-Once ; #FUNCTION# ;=============================================================================== ; ; Name...........: _StdDev ; Description ...: Returns the standard deviation between all numbers stored in an array ; Syntax.........: _StdDev($anArray, $iStdFloat) ; Parameters ....: $anArray - An array containing 2 or more numbers ;                  $iStdFloat - (Optional) The number of decimal places to round for STD ;                  $iType - (Optional) Decides the type of Standard Deviation to use: ;                  |1 - Method One (Standard method using Mean) ;                  |2 - Method Two (Non-Standard method using Squares) ; Return values .: Success - Standard Deviation between multiple numbers ;                  Failure - Returns empty and Sets @Error: ;                  |0 - No error. ;                  |1 - Invalid $anArray (not an array) ;                  |2 - Invalid $anArray (contains less than 2 numbers) ;                  |3 - Invalid $iStdFloat (cannot be negative) ;                  |4 - Invalid $iStdFloat (not an integer) ; Author ........: Ealric ; Modified.......: ; Remarks .......: ; Related .......: _StdDev ; Link ..........; ; Example .......; Yes; ; ;========================================================================================== Func _StdDev(ByRef $anArray, $iStdFloat = 0, $iType = 1)     If Not IsArray($anArray) Then Return SetError(1, 0, "") ; Set Error if not an array     If UBound($anArray) <= 1 Then Return SetError(2, 0, "") ; Set Error if array contains less than 2 numbers     If $iStdFloat <= -1 Then Return SetError(3, 0, "") ; Set Error if argument is negative     If Not IsInt($iStdFloat) Then Return SetError(4, 0, "") ; Set Error if argument is not an integer     Local $n = 0, $nSum = 0     Local $iMean = _Mean($anArray)     Local $iCount = _StatsCount($anArray)     Switch $iType         Case 1             For $i = 0 To $iCount - 1                 $n += ($anArray[$i] - $iMean)^2             Next             If ($iStdFloat = 0) Then                 Local $nStdDev = Sqrt($n / ($iCount-1))             Else                 Local $nStdDev = Round(Sqrt($n / ($iCount-1)), $iStdFloat)             EndIf             Return $nStdDev         Case 2             For $i = 0 To $iCount - 1                 $n = $n + $anArray[$i]                 $nSum = $nSum + ($anArray[$i] * $anArray[$i])             Next             If ($iStdFloat = 0) Then                 Local $nStdDev = Sqrt(($nSum - ($n * $n) / $iCount) / ($iCount - 1))             Else                 Local $nStdDev = Round(Sqrt(($nSum - ($n * $n) / $iCount) / ($iCount - 1)), $iStdFloat)             EndIf             Return $nStdDev     EndSwitch EndFunc   ;==>_StdDev ; #FUNCTION#;=============================================================================== ; ; Name...........: _Mean ; Description ...: Returns the mean of a data set, choice of Pythagorean means ; Syntax.........: _Mean(Const ByRef $anArray[, $iStart = 0[, $iEnd = 0[, $iType = 1]]]) ; Parameters ....: $anArray - 1D Array containing data set ;                  $iStart - Starting index for calculation inclusion ;                  $iEnd - Last index for calculation inclusion ;                  $iType - One of the following: ;                  |1 - Arithmetic mean (default) ;                  |2 - Geometric mean ;                  |3 - Harmonic mean ; Return values .: Success - Mean of data set ;                  Failure - Returns "" and Sets @Error: ;                  |0 - No error. ;                  |1 - $anArray is not an array or is multidimensional ;                  |2 - Invalid mean type ;                  |3 - Invalid boundaries ; Author ........: Andybiochem ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; ;;========================================================================================== Func _Mean(Const ByRef $anArray, $iStart = 0, $iEnd = 0, $iType = 1)     If Not IsArray($anArray) Or UBound($anArray, 0) <> 1 Then Return SetError(1, 0, "")     If Not IsInt($iType) Or $iType < 1 Or $iType > 3 Then Return SetError(2, 0, "")     Local $iUBound = UBound($anArray) - 1     If Not IsInt($iStart) Or Not IsInt($iEnd) Then Return SetError(3, 0, "")     If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound     If $iStart < 0 Then $iStart = 0     If $iStart > $iEnd Then Return SetError(3, 0, "")     Local $nSum = 0, $iN = ($iEnd - ($iStart - 1))     Switch $iType         Case 1;Arithmetic mean             For $i = $iStart To $iEnd                 $nSum += $anArray[$i]             Next             Return $nSum / $iN         Case 2;Geometric mean             For $i = $iStart To $iEnd                 $nSum *= $anArray[$i]                 If $i = $iStart Then $nSum += $anArray[$i]             Next             Return $nSum ^ (1 / $iN)         Case 3;Harmonic mean             For $i = $iStart To $iEnd                 $nSum += 1 / $anArray[$i]             Next             Return $iN / $nSum     EndSwitch EndFunc   ;==>_Mean 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   ;==>_StatsSum Func _StatsCount(ByRef $a_Numbers)     Return UBound($a_Numbers) EndFunc   ;==>_StatsCount 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   ;==>_StatsCp 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   ;==>_StatsCpk

Edited by Ealric, 02 March 2009 - 07:55 PM.








#2 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,690 posts

Posted 27 February 2009 - 03:12 PM

Ealric,

I have worked at a previous company whereby we had to calculate Standard Deviation, as well as Estimated Deviation. I like your work. We should make some statistical functions for AutoIt as a library. Now I am working at a company that may interest you and your stats program as we work with several stats programs for sports. Company is Sound & Video Creations, Inc. branding ClickEffects.

Let me know what you think.

Regards,
Jarvis
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#3 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,565 posts

Posted 27 February 2009 - 03:27 PM

Nice but could be easy to calculate with STDEV or STDEVP with Excel. :P
When the words fail... music speaks

#4 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,690 posts

Posted 27 February 2009 - 04:22 PM

Nice but could be easy to calculate with STDEV or STDEVP with Excel. :P


While that is very true, that would also require whoever used the library to have Excel, and I don't like limiting peoples ability to use a script/library I write by having to have some proprietary program that cost a good sum of change. If it were a free program, then I probably wouldn't mind, but I also like keeping my scripts independent of most anything if possible.

Thanks,
Jarvis
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#5 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,565 posts

Posted 27 February 2009 - 04:31 PM

While that is very true, that would also require whoever used the library to have Excel, and I don't like limiting peoples ability to use a script/library I write by having to have some proprietary program that cost a good sum of change. If it were a free program, then I probably wouldn't mind, but I also like keeping my scripts independent of most anything if possible.

Thanks,
Jarvis

I said that because I hope that he take a look in help for STDEV in Excel Help File (if he didn't do that - there is describe the algorithm) and maybe then can write a code more good ( or more bad :P ).
When the words fail... music speaks

#6 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 27 February 2009 - 04:42 PM

Ealric,

I have worked at a previous company whereby we had to calculate Standard Deviation, as well as Estimated Deviation. I like your work. We should make some statistical functions for AutoIt as a library. Now I am working at a company that may interest you and your stats program as we work with several stats programs for sports. Company is Sound & Video Creations, Inc. branding ClickEffects.

Let me know what you think.

Regards,
Jarvis


Hi Jarvis,

Thanks for the interest in this. I have been working on an extremely diverse statistics program which I call GSA. I've compiled a Flash projector executable which you can download here:

http://ncaastatpages.com/GSA.exe

I tested the program in the ESPN bowl challenge and went 22 - 12 for the challenge with GSA. I saved all of the bowl comparisons for analysis. What I try to do is work towards a 5% P-value in all my statistical formulas. I'm right at around 28% P-value so I have a lot of work still to do. But, it did predict the national champion and you can play with it and let me know what you think. I would be happy to work on a statistics library if you want some help with it.

Thanks.

#7 FireFox

FireFox

    It slips through our fingers, like a fist full of sand.

  • MVPs
  • 5,270 posts

Posted 27 February 2009 - 04:57 PM

@Ealric
this is only some statistics calculations for me :P

your 'mean average' is a 'class center' for example :
$A = 20 $B = 30 If $A > $B Then     $C = $B - $A     $D = $C / 2     $E = $A - $D     MsgBox(64, 'CC', $E) Else     $C = $A - $B     $D = $C / 2     $E = $B - $D     MsgBox(64, 'CC', $E) EndIf


Cheers, FireFox.

Edited by FireFox, 27 February 2009 - 04:58 PM.

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.

Hardware : Intel® Core™ i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !


#8 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 28 February 2009 - 02:43 PM

Use Top Post for UDF.

Edited by Ealric, 02 March 2009 - 07:48 PM.


#9 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 28 February 2009 - 03:02 PM

JS,

I propose that if we do work on multiple UDFs that it be implemented in an include called "Statistics". The Standard Deviation UDF is just one - but I can think of another 2 or 3 that I use often in calculations for variance. Let me know which UDFs you want to work on with me, or give me an idea of what types of UDF you are interested in.

Thanks.

#10 andybiochem

andybiochem

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 308 posts

Posted 01 March 2009 - 08:34 AM

Hi!

1) Not sure why you'd want to include a Mean function in an SD function? what's wrong with _Mean() on its own??

2) You need to set the float for the mean calc too ... i.e. what's the mean of 0.002,0.003,0.001 ????

3) why not make the rounding optional?

4) I think you're asking for problems including the zero index element in calculations


For comparison, here are the SD, Mean, Sum, CV (Coefficient of variation), and Var (Variance) I wrote for my stats packages:
AutoIt         
Func _SD(ByRef $aArray)     $iN = UBound($aArray) - 1     $iMean = _Mean($aArray)     $iSD = 0     For $i = 1 To $iN         $iSD += ($iMean - $aArray[$i])^2     Next     Return Sqrt($iSD/$iN) EndFunc Func _CV(ByRef $aArray)     Return (_SD($aArray) / _Mean($aArray)) * 100 EndFunc Func _Var(ByRef $aArray)     Return _SD($aArray)^2 EndFunc Func _Mean(ByRef $aArray)     Return _Sum($aArray) / (UBound($aArray) - 1) EndFunc Func _Sum(ByRef $aArray)     $iSum = 0     For $i = 1 To (UBound($aArray) - 1)         $iSum += $aArray[$i]     Next     Return $iSum EndFunc

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

#11 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 01 March 2009 - 03:40 PM

Other posts updated.

Edited by Ealric, 02 March 2009 - 03:43 PM.


#12 andybiochem

andybiochem

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 308 posts

Posted 01 March 2009 - 08:32 PM

...Mean is a part of standard deviation - always will be. There's no need to apply a secondary function to calculate the mean. One function returns either result, when specified.


Then why not call your function "_Pearson_Product_Moment_Correlation_Coefficient()" ...that calculation includes SD and Mean too!!!

I don't mean to be negative - I'd like to see some good stats functions in AI too - but function names should indicate what the function does (especially if you want the UDF adding to the AI install). "_StandardDeviation()" suggests the function returns SD nothing else. Once you start to write complicated equations using mean and SD the result will be very confusing when using just one function with different flags.

The AI help file would also be unusable if functions were hidden inside other ones.

Clarity is key here.
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

#13 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 01 March 2009 - 09:09 PM

Then why not call your function "_Pearson_Product_Moment_Correlation_Coefficient()" ...that calculation includes SD and Mean too!!!

I don't mean to be negative - I'd like to see some good stats functions in AI too - but function names should indicate what the function does (especially if you want the UDF adding to the AI install). "_StandardDeviation()" suggests the function returns SD nothing else. Once you start to write complicated equations using mean and SD the result will be very confusing when using just one function with different flags.

The AI help file would also be unusable if functions were hidden inside other ones.

Clarity is key here.


Your point is noted and yes you are sounding negative and drawing too much into your observations. Nothing else is being changed here.

Thanks.

Edit: Just wanted to offer another point of clarification. The return of just the mean is "optional". The function without options returns the standard deviation as noted. So, again, I don't understand why you are up in arms over having an option in a function to return just the mean. I do understand your reasoning but I don't necessarily agree with it. My UDF follows "every guideline" posted by GaryFrost. I'll wait for further feedback from some more experienced coders before deciding any further changes.

Edited by Ealric, 01 March 2009 - 09:21 PM.


#14 andybiochem

andybiochem

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 308 posts

Posted 01 March 2009 - 09:17 PM

Well, good luck with it.

http://www.autoitscript.com/autoit3/udfs/UDF_Standards.htm
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

#15 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 01 March 2009 - 09:25 PM

Well, good luck with it.

http://www.autoitscript.com/autoit3/udfs/UDF_Standards.htm


Read my edited post earlier. I've followed all of those guidelines. Is there something within that link you want to point out specifically that you feel "I'm not" following?

#16 andybiochem

andybiochem

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 308 posts

Posted 01 March 2009 - 09:47 PM

Whatever.

I added the link because I thought it might be helpful in getting your function UDF-ready.

Don't make the mistake of thinking that my low post count means I'm not experienced.
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

#17 Ealric

Ealric

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 01 March 2009 - 09:55 PM

Whatever.

I added the link because I thought it might be helpful in getting your function UDF-ready.

Don't make the mistake of thinking that my low post count means I'm not experienced.


Andy, putting differences of opinion aside, I do not think you are "inexperienced". When I mention more experienced coders, I'm referring to coders that are more experienced "than I am". I listen to my peers - even to you (why do you think I changed the UDF to account for two changes you posted?). I make changes when they definitely are needed and you posted a very valid reason which required a change in the UDF. I did that.

I really do understand what you are getting at with the _mean function but rather than make assumptions and disect my UDF and add more functions, I simply want to wait and get some feedback from some more experienced coders. One thing that is very important to me as well as you is clarity. What I'd like to eventually do is have a library of statistics called "Statistics.au3" that houses statistical functions. However, I'm not certain that others would want _mean in that library. It's not my decision. I can only offer my input on a few UDFs that I enjoy using personally, standardize them, and make them available to others. If someone wants to put together a standardized library that is a collaborative effort, I'm all for that.

Again, just because I respond to you doesn't mean I'm berating you. Relax mate. :P

I've read your posts - you present some very good and solid ideas. Show me one person on this board that agrees with everyone 100% of the time. I don't know that person...

#18 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,690 posts

Posted 02 March 2009 - 03:51 AM

@Andy

It would seem you came to this thread with a bit of an attitude, and I don't believe anyone has challenged your coding skills. We certainly value your input as we move forward. It did seem to me you were being a bit arrogant with your statements. I don't really care as I will do whatever, but I do value input.

@Ealric

I already named my file Stats.au3, we could call it Statistics.au3 as that would be fine. I did more like Andy, and broke the functions down that way in corresponding functions we could call the same routines from each of them. Tomorrow I will post what I already have. I like your StdDev function. Looks good.

Regards,
Jarvis
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#19 andybiochem

andybiochem

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 308 posts

Posted 02 March 2009 - 08:40 AM

@Andy

It would seem you came to this thread with a bit of an attitude, and I don't believe anyone has challenged your coding skills. We certainly value your input as we move forward. It did seem to me you were being a bit arrogant with your statements. I don't really care as I will do whatever, but I do value input.

Jarvis

My apologies if I came across as arrogant... my intention was to be pragmatic.

I'm very enthusiastic about AI having some good native stats functions, perhaps I have been over-critical in my enthusiasm.


In the interest of a Statistics UDF, here's a Mean function:
Plain Text         
; #FUNCTION#;=============================================================================== ; ; Name...........: _Mean ; Description ...: Returns the mean of a data set, choice of Pythagorean means ; Syntax.........: _Mean(Const ByRef $anArray[, $iStart = 0[, $iEnd = 0[, $iType = 1]]]) ; Parameters ....: $anArray - 1D Array containing data set ;                 $iStart - Starting index for calculation inclusion ;                 $iEnd - Last index for calculation inclusion ;                 $iType - One of the following: ;                 |1 - Arithmetic mean (default) ;                 |2 - Geometric mean ;                 |3 - Harmonic mean ; Return values .: Success - Mean of data set ;                 Failure - Returns "" and Sets @Error: ;                 |0 - No error. ;                 |1 - $anArray is not an array or is multidimensional ;                 |2 - Invalid mean type ;                 |3 - Invalid boundaries ; Author ........: Andybiochem ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; ;;========================================================================================== Func _Mean(Const ByRef $anArray, $iStart = 0, $iEnd = 0, $iType = 1)     ;----- check array -----     If Not IsArray($anArray) Or UBound($anArray, 0) <> 1 Then Return SetError(1, 0, "")     ;----- check type -----     If Not IsInt($iType) Or $iType < 1 Or $iType > 3 Then Return SetError(2, 0, "")     ;----- Check bounds -----     Local $iUBound = UBound($anArray) - 1     If Not IsInt($iStart) Or Not IsInt($iEnd) Then Return SetError(3, 0, "")     If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound     If $iStart < 0 Then $iStart = 0     If $iStart > $iEnd Then Return SetError(3, 0, "")     ;----- Calculate means -----     Local $nSum = 0, $iN = ($iEnd - ($iStart - 1))     Switch $iType         Case 1;Aritmetic mean             For $i = $iStart To $iEnd                 $nSum += $anArray[$i]             Next             Return $nSum / $iN         Case 2;Geometric mean             For $i = $iStart To $iEnd                 $nSum *= $anArray[$i]                 If $i = $iStart Then $nSum += $anArray[$i]             Next             Return $nSum ^ (1 / $iN)         Case 3;Harmonic mean             For $i = $iStart To $iEnd                 $nSum += 1 / $anArray[$i]             Next             Return $iN / $nSum     EndSwitch     EndFunc;==>_Mean


Criticism welcome

[EDIT] - tidied a bit

Edited by andybiochem, 02 March 2009 - 10:15 AM.

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

#20 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,690 posts

Posted 02 March 2009 - 02:38 PM

My apologies if I came across as arrogant... my intention was to be pragmatic.

I'm very enthusiastic about AI having some good native stats functions, perhaps I have been over-critical in my enthusiasm.


In the interest of a Statistics UDF, here's a Mean function:

Plain Text         
; #FUNCTION#;=============================================================================== ; ; Name...........: _Mean ; Description ...: Returns the mean of a data set, choice of Pythagorean means ; Syntax.........: _Mean(Const ByRef $anArray[, $iStart = 0[, $iEnd = 0[, $iType = 1]]]) ; Parameters ....: $anArray - 1D Array containing data set ;                 $iStart - Starting index for calculation inclusion ;                 $iEnd - Last index for calculation inclusion ;                 $iType - One of the following: ;                 |1 - Arithmetic mean (default) ;                 |2 - Geometric mean ;                 |3 - Harmonic mean ; Return values .: Success - Mean of data set ;                 Failure - Returns "" and Sets @Error: ;                 |0 - No error. ;                 |1 - $anArray is not an array or is multidimensional ;                 |2 - Invalid mean type ;                 |3 - Invalid boundaries ; Author ........: Andybiochem ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; ; ;;========================================================================================== Func _Mean(Const ByRef $anArray, $iStart = 0, $iEnd = 0, $iType = 1)     ;----- check array -----     If Not IsArray($anArray) Or UBound($anArray, 0) <> 1 Then Return SetError(1, 0, "")     ;----- check type -----     If Not IsInt($iType) Or $iType < 1 Or $iType > 3 Then Return SetError(2, 0, "")     ;----- Check bounds -----     Local $iUBound = UBound($anArray) - 1     If Not IsInt($iStart) Or Not IsInt($iEnd) Then Return SetError(3, 0, "")     If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound     If $iStart < 0 Then $iStart = 0     If $iStart > $iEnd Then Return SetError(3, 0, "")     ;----- Calculate means -----     Local $nSum = 0, $iN = ($iEnd - ($iStart - 1))     Switch $iType         Case 1;Aritmetic mean             For $i = $iStart To $iEnd                 $nSum += $anArray[$i]             Next             Return $nSum / $iN         Case 2;Geometric mean             For $i = $iStart To $iEnd                 $nSum *= $anArray[$i]                 If $i = $iStart Then $nSum += $anArray[$i]             Next             Return $nSum ^ (1 / $iN)         Case 3;Harmonic mean             For $i = $iStart To $iEnd                 $nSum += 1 / $anArray[$i]             Next             Return $iN / $nSum     EndSwitch     EndFunc;==>_Mean


Criticism welcome

[EDIT] - tidied a bit

No biggie about the arrogance, I am happy for your enthusiasm. I like how you added the different means in your code as I didn't do that in mine. I only had the Arithmetic mean. I noticed a small typo in your comment for the Arithmetic mean (you spelled it Aritmetic).

Now to post what I have come up with, but you guys have already made your's UDF Standards Compliant. I always make working functions, then add error checking, then all the documentation needed for the Standards Include.

Thanks for contributing!
Jarvis
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users