Skip to content

Instantly share code, notes, and snippets.

@sudipto80
Created January 21, 2016 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudipto80/89253a340503f7559cce to your computer and use it in GitHub Desktop.
Save sudipto80/89253a340503f7559cce to your computer and use it in GitHub Desktop.
True rank
//Calculates the standard deviation
let stddev(list:float list)=
sqrt (List.fold (fun acc elem -> acc + (float elem - List.average list) ** 2.0 ) 0.0
list / float list.Length)
let trueRanks = [1.;2.;3.;4.;5.;5.;7.;8.;9.;10.]
let predictedRanks = [1.;2.;3.;4.;6.;7.;5.;8.;10.;9.]
let uBar = trueRanks |> List.average
let upBar = predictedRanks |> List.average
let stdevTrue = stddev trueRanks
let stdevPredicted = stddev predictedRanks
let n = 10.
let numerator = List.zip trueRanks predictedRanks
|> List.map (fun item -> (float (fst item) - uBar) * (float (snd item) - upBar))
|> List.sum
let denominator = n * stdevTrue * stdevPredicted
let p = numerator /denominator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment