Ejemplo n.º 1
0
        //BB% - Walk Percentage (http://www.fangraphs.com/library/offense/rate-stats/)
        private double CalculateBbRate(CalculatorStats stats)
        {
            var    numerator   = (double)stats.Bb;
            var    denominator = stats.Pa;
            double bbRate      = SafeDivide.divideDouble(numerator, denominator);

            return(Math.Round(bbRate, 3));
        }
Ejemplo n.º 2
0
        //SLG - Slugging Percentage
        private double CalculateSlg(CalculatorStats stats)
        {
            var numerator   = (double)stats.Singles + stats.X2b * 2 + stats.X3b * 3 + stats.Hr * 4;
            var denominator = stats.Ab;

            double slg = SafeDivide.divideDouble(numerator, denominator);

            return(Math.Round(slg, 3));
        }
Ejemplo n.º 3
0
        //OBP - On Base Percentage (http://www.fangraphs.com/library/offense/obp/)
        private double CalculateObp(CalculatorStats stats)
        {
            var numerator   = (double)stats.H + stats.Bb + stats.Ibb;
            var denominator = stats.Ab;

            double obp = SafeDivide.divideDouble(numerator, denominator);

            return(Math.Round(obp, 3));
        }
Ejemplo n.º 4
0
        //ISO - Isolated Power (http://www.fangraphs.com/library/offense/iso/)
        private double CalculateIso(CalculatorStats stats)
        {
            var numerator   = (double)stats.X2b + (2 * stats.X3b) + (3 * stats.Hr);
            var denominator = stats.Ab;

            double iso = SafeDivide.divideDouble(numerator, denominator);

            return(Math.Round(iso, 3));
        }
Ejemplo n.º 5
0
        //BABIP - Batting Average On Balls In Play (http://www.fangraphs.com/library/offense/babip/)
        private double CalculateBabip(CalculatorStats stats)
        {
            var numerator   = (double)stats.H - stats.Hr;
            var denominator = stats.Ab - stats.So - stats.Hr + stats.Sf;

            double babip = SafeDivide.divideDouble(numerator, denominator);

            return(Math.Round(babip, 3));
        }
Ejemplo n.º 6
0
        //AVG - Batting Average
        private double CalculateAvg(CalculatorStats stats)
        {
            double avg = SafeDivide.divideDouble((double)stats.H, stats.Ab);

            return(Math.Round(avg, 3));
        }