Quadruple convolution to determine pro points at 4 PTs

Jul 31st, 2016
266
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. /*
2.  * To change this template, choose Tools | Templates
3.  * and open the template in the editor.
4.  */
5. package convolution;
6.
7. /**
8.  *
9.  * @author fkarsten
10.  */
11. public class CONVOLUTION {
12.
13.     /**
14.      * @param args the command line arguments
15.      */
16.     public static void main(String[] args) {
17.
18.         double[] Probability = new double[121];
19.         int TotalPoints;
20.         double TotalProb;
21.
22.         //Initialize
23.         for (int i=1; i<=120; i++){
24.             Probability[i]=0;
25.         }
26.
27.         for (int Sit1=1; Sit1<=9; Sit1++){
28.             for (int Sit2=1; Sit2<=9; Sit2++){
29.                 for (int Sit3=1; Sit3<=9; Sit3++){
30.                     for (int Sit4=1; Sit4<=9; Sit4++){
31.                         //For each of the four PTs, there are 9 situations corresponding to 9 different possible pro point amounts
32.                         TotalPoints=getPoints(Sit1)+getPoints(Sit2)+getPoints(Sit3)+getPoints(Sit4);
33.                         TotalProb=getProb(Sit1)*getProb(Sit2)*getProb(Sit3)*getProb(Sit4);
34.                         Probability[TotalPoints]=Probability[TotalPoints]+TotalProb;
35.                     }
36.                 }
37.             }
38.         }
39.
40.         for (int i=1; i<=120; i++){
41. //            System.out.println("The probability of getting "+i+" pro points over the season is "+Probability[i]);
42.               System.out.println(Probability[i]);
43.         }
44.     }
45.
46.     public static int getPoints(int Sit){
47.         int value=0;
48.         if (Sit==1) {value=3;}
49.         if (Sit==2) {value=4;}
50.         if (Sit==3) {value=6;}
51.         if (Sit==4) {value=10;}
52.         if (Sit==5) {value=15;}
53.         if (Sit==6) {value=18;}
54.         if (Sit==7) {value=22;}
55.         if (Sit==8) {value=26;}
56.         if (Sit==9) {value=30;}
57.         return value;
58.     }
59.
60.     public static double getProb(int Sit){
61.         double value=0;
62.         if (Sit==1) {value=0.351;}
63.         if (Sit==2) {value=0.167;}
64.         if (Sit==3) {value=0.185;}
65.         if (Sit==4) {value=0.151;}
66.         if (Sit==5) {value=0.063;}
67.         if (Sit==6) {value=0.042;}
68.         if (Sit==7) {value=0.021;}
69.         if (Sit==8) {value=0.010;}
70.         if (Sit==9) {value=0.010;}
71.         return value;
72.     }
73.
74. }
RAW Paste Data