Snippets

Tuomas Hietanen Average Square Error

Created by Tuomas Hietanen
// In statistics, one of the standard ways to calculate an estimate/estimation quality, 
// to be able to compare how good are different estimates.

let inline averageSquareError estimated actual = 
    Array.zip estimated actual
    |> Array.averageBy (fun (w,o) -> pown (o - w) 2)

//let estimated = [|1.0; 2.0; 3.0; 4.0; 5.0|]
//let actual    = [|1.1; 2.2; 2.8; 4.0; 5.1|]

//let err = averageSquareError estimated actual
//val err : float = 0.02

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.