locked
F# TrueSkill RRS feed

  • Question

  • I have trouble understanding the following two lines in the F# code for TrueSkill:

    letskills = skillsPrior nPlayers

    letskills, synthetic_results = prior nPlayers matches

    I copied the two functions below where these two statements are in.

    Could someone explain these to me? What types are defined here?

    The second statement is "let pattern=expression"? 2-tuple? 3-tuple?

    Thank you very much in advance! - Min

    [<ReflectedDefinition>]

    let

    prior (nPlayers: int) (matches: (int*int)[]) =

    letskills = skillsPrior nPlayers

    letresults = [| for(p1, p2) inArray.toList matches ->performanceDiff skills p1 p2|]

      skills, results

    [<ReflectedDefinition>]

    let

    posterior (nPlayers: int, games: Game[]) =

    letmatches = [| for(p1, p2, _) ingames ->(p1, p2) |]

    letskills, synthetic_results = prior nPlayers matches

    for(diff, (_, _, outcome)) inArray.toList (Array.zip synthetic_results games) do

    ifoutcome = 1 then

          observe (diff > drawMargin)  

    elseifoutcome = -1 then

          observe (diff < -drawMargin)

    else

          observe ((diff >= -drawMargin) && (diff <= drawMargin))

      skills


    Monday, May 13, 2013 8:47 PM

All replies

  • Hi,

    The function prior returns a pair of float arrays, i.e. (float[] * float[]). This is equivalent to System.Generic.Tuple<double[],double[]> if you're more familiar with C#. 

    The definition

    let skills, synthetic_results = prior nPlayers matches

    simply takes that tuple apart, binding its components to identifiers skills (of type float[]) and synthetic_results (of type float[]).

    Hope that helps,

    Claudio

    PS. In VS, you can see the types of F# identifiers just by hovering over them with the mouse.


    Wednesday, May 15, 2013 4:51 PM
  • Thank you very much!
    Thursday, May 16, 2013 11:39 PM