-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMath.au3
98 lines (66 loc) · 1.6 KB
/
Math.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#cs ---------------------------------------
Author: Robert Schnitman
Date: 2020-06-09
Last Modified: 2020-06-09
Description: A collection of custom
math functions for AutoIt.
List of Functions:
1. Sum()
2. Mean()
#ce ---------------------------------------
;========================================
#cs ---------------------------------------
Author: Robert Schnitman
Date: 2020-06-09
Function: Sum()
Description: Summation of all elements in
an array.
#ce ---------------------------------------
Func Sum($a)
$x = 0
For $i = 0 to UBound($a) - 1
$x += $a[$i]
Next
Return $x
EndFunc
#cs -- TEST
Local $array = [1, 2, 3, 4, 5]
MsgBox(1, 'Sum of $array', Sum($array))
#ce --
;========================================
#cs ---------------------------------------
Author: Robert Schnitman
Date: 2020-06-09
Function: Mean()
Description: Average of all elements in
an array.
#ce ---------------------------------------
Func Mean($a)
Return Sum($a)/UBound($a)
EndFunc
#cs -- TEST
Local $array = [1, 2, 3, 4, 5]
MsgBox(1, 'Mean of $array', Mean($array))
#ce --
;========================================
#cs
#cs ---------------------------------------
Author: Robert Schnitman
Date: 2020-06-09
Function: SD()
Description: Standard deviation of all
elements in an array.
#ce ---------------------------------------
Func SD($a)
Local $num[UBound($a)] = [0]
For $i = 0 to UBound($a) - 1
$num[$i] = ($a[$i] - Mean($a))^2
Next
Return Sqrt(Mean($num))
EndFunc
;#cs -- TEST
#include <Array.au3>
Local $array = [1, 2, 3, 4, 5]
MsgBox(1, 'SD of $array', SD($array))
;#ce --
#ce