Exemplo n.º 1
0
        /// <summary>
        /// 获得Qp相关的组合,只针对PLC_CNT=3的情况
        /// </summary>
        /// <param name="comb"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private static int[] getQpRelationIndice(common.Math.Combination comb, int index)
        {
            if (comb.M != 2)
            {
                return(null);
            }
            int[]      c   = comb.Combine(index);
            List <int> ret = new List <int>();

            ret.Add(index);

            for (int i = 0; i < comb.N; i++)
            {
                if (Array.IndexOf(c, i) == -1)
                {
                    ret.Add(comb.Index(new int[] { i, c[0] }));
                    ret.Add(comb.Index(new int[] { i, c[1] }));
                }
            }
            return(ret.ToArray());
        }
Exemplo n.º 2
0
        public static double[][] calcMinMaxOddsForQp(HrsTable table, double[] betRate, double r)
        {
            if (betRate == null)
            {
                return(null);
            }
            int CNT     = table.Count;
            int PLC_CNT = 3;

            if (CNT <= table.PLC_SPLIT_POS)
            {
                PLC_CNT = 2;
            }

            common.Math.Combination comb = new common.Math.Combination(CNT, 2);
            if (betRate.Length != comb.Length)
            {
                return(null);
            }


            if (PLC_CNT == 2)
            {
                double[] odds = betRate.Select(x => r < x ? 1 : r / x).ToArray();
                return(new double[][] { odds, odds });
            }
            else
            {
                double[] odds_min = new double[betRate.Length];
                double[] odds_max = new double[betRate.Length];
                for (int i = 0; i < betRate.Length; i++)
                {
                    //int[] rel_indices = getQpRelationIndice(comb, i);
                    //double[] rel_rates = new double[rel_indices.Length];
                    //for (int j = 0; j < rel_indices.Length; j++) rel_rates[j] = betRate[rel_indices[j]];
                    //IOrderedEnumerable<double> sorted_rate = rel_rates.OrderByDescending(x => x);

                    double br0 = betRate[i];
                    int[]  c = comb.Combine(i);
                    double min = double.MaxValue, max = double.MinValue;
                    for (int j = 0; j < CNT; j++)
                    {
                        if (Array.IndexOf(c, j) == -1)
                        {
                            double br1 = betRate[comb.Index(new int[] { j, c[0] })];
                            double br2 = betRate[comb.Index(new int[] { j, c[1] })];

                            double od = 1 + (r - br1 - br2 - br0) / 3 / br0;
                            if (od < min)
                            {
                                min = od;
                            }
                            if (od > max)
                            {
                                max = od;
                            }
                        }
                    }
                    odds_min[i] = min;
                    odds_max[i] = max;
                }
                return(new double[][] { odds_min, odds_max });
            }
        }