# Stat.au3 - statistics-UDF for AutoIt

## Recommended Posts

This UDF provides functionality for statistical hypothesis testing, descriptive sample statistics, propability distributions and numerical mathematics:

• probability distributions (probality density, cumulative density and quantile function) for:
• continuous uniform distribution
• gaussian normal distribution (also standard normal distribution) + random number generation
• F-distribution
• Student-t-distribution
• Beta-distribution
• Chi²-distribution
• Kolmogorov-Smirnov distribution
• statistical hypothesis tests:
• one sample Kolmogorov-Smirnov-test
• Lilliefors-Test
• unpaired two sample student's t-test
• unpaired two sample Welch-test
• F-test for variance equality
• Wilcoxon-Mann-Whitney-Test
• combined test with condition check for these tests
• descriptive statistics:
• arithmetic mean, modal value, median
• standard deviation, average deviation, standard error of mean, variance, skewness, curtosis
• minima, maxima, range, sum, length
• quantiles
• ranks
• histogram
• numerical mathematics:
• single parameter function solver and root finding
• single parameter integration
• basic funtions:
• Gamma-function (gamma, log-gamma, inverse gamma, incomplete gamma)
• Gauss error function, complementary Gauss error function, inverse complementary Gauss error function
• Beta-function (beta, incomplete beta, regularized incomplete beta, inversed regularized incomplete beta
• inverse of x * log(x)

What can you do with it?
Well, you could for example check if the AutoIt-Random function really returns evenly distributed values:

Spoiler
```#include "Stat.au3"

; create AutoIt sample data
Local Const \$N = 1e3
Local \$a_Sample[1e3]
Local \$lower = 0, \$upper = 100
For \$i = 0 To \$N -1
\$a_Sample[\$i] = Random(\$lower, \$upper)
Next

; Test for uniform distribution:
Local \$a_Params = ["CallArgArray", 0, \$lower, \$upper]
\$a_Ret = _stat_test_KS(\$a_Sample, 0.05, _stat_uniform_cdf, \$a_Params)
_ArrayDisplay(\$a_Ret, "Is Random() uniformly distributed?")
MsgBox(0, "Is Random() uniformly distributed?", (\$a_Ret ? "Random is uniformly distributed" : "Random is NOT uniformly distributed"))```

Or you can check whether two samples have the same mean value (with normal distribution) or the same central tendency.
The function automatically checks the respective prerequisites for the internal tests:

Spoiler
```#include "Stat.au3"

; Test whether two samples have the same mean values (with normal distribution) or central tendencies.
Local \$a_Sample1, \$a_Sample2
For \$i = 0 To 999
; generates normally distributed samples (for t- and Welch-test)
\$a_Sample1[\$i] = _stat_norm_ran(100, 5)
\$a_Sample2[\$i] = _stat_norm_ran(99.0, 4.5)
; generates non-normally distributed samples (for Wilcoxon blablabla test)
;  \$a_Sample1[\$i] = Random(0,100)
;  \$a_Sample2[\$i] = Random(10,90)
Next

\$a_Results = _stat_test_SampleEquality(\$a_Sample1, \$a_Sample2)
_ArrayDisplay(\$a_Results, "test results")
MsgBox(0, "", \$a_Results ? "Samples have equal values on average" : "Samples have different values on average")

; ========== Test pattern of _stat_test_SampleEquality =============
;   If both samples are normally distributed (Lilliefors test):
;       If variances are equal (F-test):
;            t-test
;       else:
;            Welch-Test
;   else:
;       Wilcoxon-Mann-Whitney-Test```

##### Share on other sites

Added this UDF to the wiki.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
WebDriver - Wiki

##### Share on other sites

Running Stat_Tests.au3 i got error:

Quote

---------------------------
Fehler
---------------------------
Kein Zugriff auf msvcrt.dll!
---------------------------
OK
---------------------------

##### Share on other sites

You need the msvc runtime.
Should be this one: >>Visual C++ Redistributable<<

Alternatively, it would also work to put the corresponding DLL into the script directory.

Interesting to see that German parts are still present in the UDF. 🙃

Edited by AspirinJunkie
##### Share on other sites
45 minutes ago, AspirinJunkie said:

Alternatively, it would also work to put the corresponding DLL into the script directory.

Found: "C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9625_none_508ef7e4bcbbe589\msvcr90.dll" and copied to @scriptdir did the job.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...