Created
January 24, 2012 19:05
-
-
Save danielkorzekwa/1671919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dk.tennisprob | |
object TennisProbCalc { | |
object MatchTypeEnum extends Enumeration { | |
type MatchTypeEnum = Value | |
val THREE_SET_MATCH, FIVE_SET_MATCH = Value | |
} | |
} | |
import TennisProbCalc.MatchTypeEnum._ | |
trait TennisProbCalc { | |
/** | |
* Calculates average probability of winning a point by a player against other players he played. | |
* | |
* @param firstServeProb Probability of a first serve. 1-firstServeProb is a probability of missing the first serve. | |
* @param firstServeWinProb Probability of winning a point on a first serve. | |
* @param secondServeWinProb Probability of winning a point on a second serve. | |
* | |
*/ | |
def pointAvgProb(firstServeProb: Double, firstServeWinProb: Double, secondServeWinProb: Double): Double | |
/** | |
* Calculates probability of winning a point on serve by player A against player B. | |
* | |
* @param winOnServeProb Probability of winning a point on serve by player A against the 'field' (average player). | |
* @param winOnReturnOpponentProb Probability of winning a point on return by player B against the 'field' (average player). | |
* @param winOnReturnAvgProb Probability of winning a point on return by the field (average player). | |
*/ | |
def pointProb(winOnServeProb: Double, winOnReturnOpponentProb: Double, winOnReturnAvgProb: Double): Double | |
/** | |
* Calculates probability of winning a tennis game by player on serve. | |
* | |
* @param pointProb Probability of winning a point by a player on serve | |
*/ | |
def gameProb(pointProb: Double): Double | |
/** | |
* Calculates probability of winning a tennis tie break. | |
* | |
* @param pointProbOnServe Probability of winning a point when serving | |
* @param pointProbOnReceive Probability of winning a point when receiving serve | |
*/ | |
def tiebreakProb(pointProbOnServe: Double, pointProbOnReceive: Double): Double | |
/** | |
* Calculates probability of winning a tennis set. | |
* | |
* @param pointProbOnServe Probability of winning a point when serving | |
* @param pointProbOnReceive Probability of winning a point when receiving serve | |
*/ | |
def setProb(pointProbOnServe: Double, pointProbOnReceive: Double): Double | |
/** | |
* Calculates probability of winning a tennis match. | |
* | |
* @param pointProbOnServe Probability of winning a point when serving | |
* @param pointProbOnReceive Probability of winning a point when receiving serve | |
* @param matchType Three or Five set match. | |
*/ | |
def matchProb(pointProbOnServe: Double, pointProbOnReceive: Double,matchType:MatchTypeEnum): Double | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment