SHARE
TWEET

CAN I HAZ CHEEZBERGER?!?!?!?

a guest Aug 25th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //~~~~~ MAIN PROGRAM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  2. //```````````````````````````````````````````````````````````````````````````````````
  3. int main() {
  4.     //random seed
  5.     randSeed();
  6.     //run R5
  7.     int tNum; //roll count
  8.     int A; //first die count
  9.     int B; //second die count
  10.     //get info from user
  11.     printf("enter roll count:"); scanf("%d",&tNum);
  12.     printf("enter first die count:"); scanf("%d",&A);
  13.     printf("enter second die count:"); scanf("%d",&B);
  14.     //run simulation
  15.     double CR_TOT = 0.0;
  16.     int z;
  17.     int dieA[tNum];
  18.     int dieB[tNum];
  19.     printf("dieA\tdieB\tRAB\t\tCR\n");
  20.     for (z = 0; z < tNum; z++) {
  21.         int k;
  22.         rollFunc(&k,A);
  23.         dieA[z] = k;
  24.         rollFunc(&k,B);
  25.         dieB[z] = k;
  26.         double COEFF_A = B*1.0/((A+B)*1.0);
  27.         double COEFF_B = A*1.0/((A+B)*1.0);
  28.         double RAB;
  29.         RAB = COEFF_A*dieA[z] + COEFF_B*dieB[z];
  30.         double DEN = 2.0*A*B/((A+B)*1.0);
  31.         double NUM = B*1.0/((A+B)*1.0) + A*1.0/((A+B)*1.0);
  32.         double CR;
  33.         CR = (RAB - NUM)/(DEN - NUM);
  34.         CR_TOT += CR;
  35.         printf("%d\t%d\t%f\t%f\n",dieA[z],dieB[z],RAB,CR);
  36.     }
  37.     CR_TOT = CR_TOT/tNum;
  38.     printf("Average on Roll Stack: %f\n",CR_TOT);
  39.     return 0;
  40. }
  41. //~~~~~ FUNCTIONS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  42. #include"statDefs.h"        //statisticl algorithms
  43. #include"arrayDefs.h"       //array methods
  44. #include"determinant.h"     //classic determinant
  45. #include"linearAlgebra.h"   //linear algebraic methods
  46. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ ~  ~   ~
  47. // ^^^ ABOVE IS OFTEN BLOATED AS CODE IS COPIED UNTIL PURSUED IN ACTIVE MARKET ^^^
  48. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  49. //~~~~~ functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`',
  50. void dUb(int *kIn) {
  51.     double RAND = pRand();
  52.     if(RAND < 0.5) {*kIn = 1;}
  53.     else           {*kIn = 2;}
  54. }
  55. void tRp(int *kIn) {
  56.     double RAND = pRand();
  57.     if(RAND < 0.25)      {*kIn = 1;}
  58.     else if (RAND < 0.5) {*kIn = 2;}
  59.     else if (RAND < .75) {*kIn = 3;}
  60.     else {tRp(kIn);}
  61. }
  62. //variate roll functor
  63. void rollFunc(int *rOut,int A) {
  64.     double RAND = pRand();
  65.     double STEP = 1.0/A;
  66.     double CHECK = STEP;
  67.     int RESPONSE = 1;
  68.     while (CHECK < RAND) {
  69.         RESPONSE += 1;
  70.         CHECK += STEP;
  71.     }
  72.     *rOut = RESPONSE;
  73. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top