Category Archives: Math

Testing the statistics functions

To enable repeatable testing of the statistical functions I’m creating I decided to create a test script. $data1 = @(1,2,3,4,5,6,7,8,9,10) $data2 = @(21,22,23,24,25,26,27,28,29,30) get-mean -numbers $data1 get-mean -numbers $data2 get-standarddeviation -numbers $data1 get-standarddeviation -numbers $data2 get-correlation -numbers1 $data1 -numbers2 $data2 … Continue reading

Posted in Math, PowerShell V2 | Leave a comment

Calculating the correlation coefficient

This measures the degree of dependence between two sets of values – +1 indicates perfect positive correlation 0 indicates no correlation -1 indicates perfect negative correlation We can calculate the correlation coefficient using this function function get-correlation { [CmdletBinding()] param … Continue reading

Posted in Math, PowerShell V2 | Leave a comment

Standard Deviation

Another simple calculation in PowerShell function get-standarddeviation { [CmdletBinding()] param ( [double[]]$numbers ) $avg = $numbers | Measure-Object -Average | select Count, Average $popdev = 0 foreach ($number in $numbers){ $popdev += [math]::pow(($number – $avg.Average), 2) } $sd = [math]::sqrt($popdev … Continue reading

Posted in Math, Powershell Basics | Leave a comment

Mean and moody

Been looking at some simple statistical calculations.  First off calculating the mean (arithmetic mean aka average in layman’s speak) For this we can use Measure-Object   function get-mean { [CmdletBinding()] param ( [double[]]$numbers ) $result = $numbers | Measure-Object -Average … Continue reading

Posted in Math, Powershell Basics | Leave a comment