locked
How to integrate match strength when updating players' skills (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • shengbo posted on 02-25-2010 5:45 AM

    Thanks John for posting the TrueSkill implementation code. I am very interested in integrating the match strength when updating players' skills. To accomplish this, I introduce a Gamma distribution on the difference between two players' performance. And I model the observed match strength variable with a Poission distribution. Note that the lambda parameter for the Poisson is the experiential of the Gamma variable. Now, suppose we observe the match strength to be 2, I thus set the constraint on the Poisson variable to be 2 in order to make inference. However, I can not compile my code (slightly modify John's c# code ). Please help me with this.

    My code could be accessed via http://users.cecs.anu.edu.au/~sguo/TrueSkill.cs Sorry, I have difficulty in putting the code here.

    Thanks for your time and help!

    Regards,

    Shengbo

    Friday, June 3, 2011 5:34 PM

Answers

All replies

  • minka replied on 02-25-2010 5:56 AM

    What is the error message that you are getting from Infer.NET?

    Friday, June 3, 2011 5:34 PM
  • shengbo replied on 02-25-2010 6:13 AM

    Thanks Tom! Here are the error messages: 

    Error 1 The best overloaded method match for 'MicrosoftResearch.Infer.Models.Variable.GammaFromMeanAndVariance(double, double)' has some invalid arguments C:\Documents and Settings\sguo\My Documents\Infer.NET 2.3\infernet2\Practical\TrueSkill\TrueSkill.cs 33 26 TrueSkill

    Error 2 Argument '1': cannot convert from 'MicrosoftResearch.Infer.Models.Variable<double>' to 'double' C:\Documents and Settings\sguo\My Documents\Infer.NET 2.3\infernet2\Practical\TrueSkill\TrueSkill.cs 33 60 TrueSkill

    Error 3 The best overloaded method match for 'System.Math.Exp(double)' has some invalid arguments C:\Documents and Settings\sguo\My Documents\Infer.NET 2.3\infernet2\Practical\TrueSkill\TrueSkill.cs 35 54 TrueSkill

    Error 4 Argument '1': cannot convert from 'MicrosoftResearch.Infer.Models.Variable<double>[]' to 'double' C:\Documents and Settings\sguo\My Documents\Infer.NET 2.3\infernet2\Practical\TrueSkill\TrueSkill.cs 35 63 TrueSkill

    Friday, June 3, 2011 5:34 PM
  • DavidKnowles replied on 02-26-2010 5:07 AM

    I think you should be using a Gaussian distribution for the difference between two players' performance (the difference of two Gaussians is Gaussian distributed, not Gamma distributed). When you take the exponential of a Gaussian Infer.Net will give you a Gamma variable you can use as the rate parameter for your Poisson. Note that you need to set the observed value of the strength. This code should give you the idea:

     

     

     

     

    var Difference = Variable.GaussianFromMeanAndPrecision(Performance[0] - Performance[1], (beta * beta)/2);

     

     

    var strength = Variable.Poisson(Variable.Exp(Difference));

    strength.ObservedValue = 2;

    I hope that helps!

    Friday, June 3, 2011 5:34 PM
  • shengbo replied on 02-26-2010 6:45 AM

    Thanks DavidKnowles for your help. I have revised my code according to your suggestions. It works.

    However, there is a problem when I set the value for the observed variable strength. For example, when I set it to 5 or 6, there is a warning saying that "result is nan". The waring happens at the line: 

    skillPosterior[ i ] = engine.Infer<Gaussian>(Skill[ i ]);

    (For the updated code, please visit: http://users.cecs.anu.edu.au/~sguo/TrueSkill.cs ) I think it may be caused by some numerical problem. Is there any way to handle this?

     

    Thanks a lot! 

     

    Friday, June 3, 2011 5:35 PM
  • DavidKnowles replied on 02-26-2010 7:11 AM

    Your new code runs fine for me even with the strength set to 100. Are you using the most up to date version of Infer.NET?

    Friday, June 3, 2011 5:35 PM
  • shengbo replied on 02-26-2010 6:56 PM

    Thanks a lot! I just changed to the most up to date version, and there is no problem. 

    Cheers, 

    Shengbo

    Friday, June 3, 2011 5:35 PM
  • shengbo replied on 03-01-2010 3:34 AM

    > When you take the exponential of a Gaussian Infer.Net will give you a Gamma variable you can use as the rate parameter for your Poisson.

    Does anyone know how Infer.Net approximates the posterior of the Gaussian, when observing a Poisson variable with its parameter being the exponential of this Gaussian variable? In other words, I expect to know how Infer.Net perform the inference. 

    Thanks!

    Cheers, 

    Shengbo

    Friday, June 3, 2011 5:35 PM
  • minka replied on 03-01-2010 3:54 AM

    The default algorithm is Expectation Propagation.  So in this case, the approximate posterior is the Gaussian whose moments match the true posterior.

    Friday, June 3, 2011 5:35 PM
  • shengbo replied on 03-01-2010 4:14 AM

    Thanks Tom!

    So, Infer.Net first computes the mean and variance of the posterior distribution, which is a Gaussian multiplied by a Poisson with its parameter being the exponential of the Gaussian variable.

    May I ask whether there is a closed-form estimation of the mean and variance for the posterior? I can not work that out. Thanks for your help!

    Cheers, 

    Shengbo

    Friday, June 3, 2011 5:35 PM
  • minka replied on 03-01-2010 5:01 AM

    I don't think there is a simple formula for the mean and variance, that only uses elementary functions.

    Friday, June 3, 2011 5:35 PM
  • shengbo replied on 03-01-2010 5:14 AM

     

     

    Friday, June 3, 2011 5:35 PM