Advertisement
Guest User

Express Entry pool simulation by Michal Pleban on 28.03.2015

a guest
Mar 28th, 2015
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.32 KB | None | 0 0
  1. #!/usr/bin/php -q
  2. <?php
  3.  
  4. ///////////////////////////////////////////////////////////
  5. //
  6. // Express Entry statistical model by Michal Pleban.
  7. //
  8. // Created on 28.03.2015.
  9. //
  10. ///////////////////////////////////////////////////////////
  11.  
  12. // !!! The most important parameter !!!
  13. // Relation of the Excel population to the real pool population
  14. $EXCEL_SHARE = 0.050;
  15.  
  16. // Number of people in the Excel on day 0
  17. $EXCEL_START = 813;
  18.  
  19. // Number of people added daily to the Excel
  20. $EXCEL_DAILY = 6.2;
  21.  
  22. // Maximum score on day 0
  23. $CUTOFF_START = 452;
  24.  
  25. // Probability of someone having LMIA/PNP
  26. $LMIA_PROB = 0.05;
  27.  
  28. // Number of days between draws
  29. $DRAW_DAYS = 16;
  30.  
  31. // Number of people in each draw
  32. $DRAW_SIZE = 1600;
  33.  
  34. // Computed real pool parameters
  35. $POOL_START = $EXCEL_START / $EXCEL_SHARE;
  36. $POOL_DAILY = $EXCEL_DAILY / $EXCEL_SHARE;
  37.  
  38. // Sample scores from Excel (for distribution)
  39. $EXCEL_SCORES = array(527, 526, 525, 518, 516, 514, 509, 506, 502, 500, 496, 496, 496, 494, 491, 491, 491, 490, 490, 489, 487, 486, 485, 484, 483, 482, 482, 481, 481, 481, 481, 481, 481, 480, 479, 478, 478, 478, 478, 478, 477, 476, 475, 475, 475, 474, 474, 473, 473, 473, 472, 472, 472, 472, 471, 471, 471, 471, 471, 470, 470, 469, 469, 469, 469, 469, 468, 468, 468, 468, 467, 467, 467, 466, 466, 466, 466, 465, 465, 464, 462, 462, 462, 462, 460, 460, 459, 459, 458, 458, 457, 457, 457, 457, 456, 456, 456, 456, 456, 456, 456, 455, 455, 454, 454, 454, 454, 453, 453, 453, 453, 453, 452, 451, 451, 451, 451, 451, 451, 451, 450, 450, 450, 449, 449, 449, 449, 449, 448, 448, 448, 447, 447, 446, 446, 444, 444, 444, 444, 444, 444, 444, 444, 443, 443, 443, 442, 442, 441, 441, 441, 441, 441, 441, 441, 440, 440, 440, 439, 439, 438, 438, 438, 438, 438, 438, 438, 438, 438, 437, 437, 437, 437, 437, 437, 437, 436, 436, 436, 436, 436, 436, 435, 435, 435, 435, 435, 435, 434, 434, 434, 434, 433, 433, 433, 433, 433, 432, 432, 432, 432, 432, 432, 431, 431, 431, 431, 431, 431, 430, 430, 430, 430, 429, 429, 429, 428, 428, 428, 428, 427, 427, 427, 427, 427, 427, 427, 427, 427, 426, 426, 425, 425, 425, 424, 424, 423, 423, 423, 423, 422, 422, 422, 421, 421, 421, 421, 421, 421, 420, 419, 419, 419, 419, 419, 419, 418, 418, 418, 418, 418, 418, 418, 417, 417, 417, 416, 416, 416, 416, 415, 415, 415, 415, 415, 415, 414, 414, 414, 414, 414, 414, 414, 413, 413, 413, 413, 413, 413, 413, 413, 413, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 411, 410, 410, 410, 410, 410, 410, 410, 410, 409, 409, 409, 409, 408, 408, 407, 407, 406, 406, 406, 406, 405, 405, 405, 405, 405, 404, 404, 404, 404, 403, 403, 403, 403, 402, 402, 402, 401, 401, 400, 400, 400, 400, 400, 400, 399, 399, 399, 399, 399, 399, 399, 399, 398, 398, 398, 398, 397, 396, 396, 396, 396, 396, 395, 395, 395, 395, 394, 394, 394, 394, 393, 393, 393, 393, 393, 393, 393, 393, 392, 392, 392, 392, 391, 390, 390, 390, 390, 390, 390, 390, 390, 389, 389, 389, 389, 388, 388, 388, 387, 387, 387, 387, 387, 387, 387, 386, 386, 386, 386, 385, 385, 385, 385, 385, 385, 385, 384, 384, 384, 384, 384, 383, 383, 383, 383, 383, 383, 383, 383, 383, 382, 382, 382, 382, 382, 382, 382, 382, 382, 382, 381, 381, 381, 381, 381, 381, 381, 381, 381, 380, 380, 380, 380, 379, 379, 379, 379, 379, 379, 379, 379, 379, 379, 378, 378, 378, 378, 378, 378, 378, 378, 378, 377, 377, 377, 377, 377, 377, 377, 377, 377, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 375, 375, 375, 375, 374, 374, 374, 374, 374, 374, 374, 373, 373, 373, 373, 373, 373, 373, 373, 372, 372, 372, 372, 372, 372, 372, 371, 371, 371, 371, 370, 370, 370, 370, 370, 369, 369, 369, 369, 369, 369, 369, 369, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 367, 367, 367, 366, 366, 366, 366, 366, 366, 366, 366, 365, 365, 365, 365, 365, 365, 365, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, 363, 363, 363, 363, 363, 362, 362, 362, 362, 362, 362, 362, 362, 362, 361, 361, 361, 361, 361, 360, 360, 360, 360, 360, 360, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 358, 358, 358, 358, 358, 358, 358, 357, 357, 357, 357, 357, 357, 357, 357, 357, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 355, 355, 355, 355, 355, 355, 355, 355, 354, 354, 354, 354, 354, 354, 354, 354, 354, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 353, 352, 352, 352, 352, 352, 352, 352, 352, 351, 351, 351, 351, 351, 351, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 349, 349, 349, 349, 349, 349, 349, 349, 348, 348, 348, 348, 348, 347, 347, 347, 346, 346, 346, 345, 345, 345, 345, 345, 344, 344, 344, 344, 344, 343, 343, 342, 342, 342, 342, 341, 341, 341, 341, 341, 341, 341, 341, 341, 340, 340, 340, 340, 340, 340, 340, 339, 339, 339, 338, 338, 338, 338, 338, 338, 337, 337, 337, 337, 337, 336, 336, 336, 336, 335, 335, 335, 335, 335, 335, 335, 334, 334, 334, 334, 334, 334, 334, 334, 334, 333, 333, 333, 333, 333, 333, 332, 332, 332, 332, 332, 331, 331, 331, 331, 330, 330, 330, 330, 330, 329, 329, 329, 329, 329, 328, 328, 327, 327, 327, 327, 327, 327, 327, 326, 326, 326, 326, 326, 326, 325, 325, 324, 324, 324, 324, 324, 324, 323, 323, 323, 322, 322, 322, 322, 322, 321, 321, 320, 320, 320, 320, 319, 318, 317, 317, 316, 316, 314, 314, 314, 314, 314, 313, 312, 312, 312, 311, 311, 311, 311, 310, 310, 309, 309, 308, 307, 307, 307, 306, 306, 306, 306, 303, 301, 301, 299, 298, 296, 296, 293, 292, 289, 289, 289, 288, 286, 284, 283, 280, 278, 278, 275, 272, 271, 269, 264, 261, 259, 252, 250, 236, 229, 226, 217, 211, 206, 204, 194);
  40.  
  41. /////////////////////////////////////////////////////
  42.  
  43. // Create an initial pool on day 0
  44. $POOL = array();
  45. while(count($POOL) < $POOL_START)
  46. {
  47.     $score = get_score();
  48.     if($score <= $CUTOFF_START) $POOL[] = $score;
  49. }
  50.  
  51. // Run the loop for four months
  52. for($day = 1; $day < 130; $day++)
  53. {
  54.     // Add new people to the pool
  55.     for($i = 0; $i < $POOL_DAILY; $i++)
  56.     {
  57.     $score = get_score();
  58.     if(rand(0, 999)/1000 <= $LMIA_PROB) $score += 600;
  59.     $POOL[] = $score;
  60.     }
  61. //    echo "Day #" . $day . ", the pool has " . count($POOL) . " members.\n";
  62.    
  63.     // Do a draw
  64.     if($day % $DRAW_DAYS == 0)
  65.     {
  66.     rsort($POOL);
  67.     for($i = 0; $i < $DRAW_SIZE; $i++)
  68.     {
  69.         $score = array_shift($POOL);
  70.     }
  71.     echo "Draw #" . (++$DRAW) . ", cutoff score = " . $score . "\n";
  72.     }
  73. }
  74.  
  75. // Function to return a random score
  76. function get_score()
  77. {
  78.     global $EXCEL_SCORES;
  79.     return $EXCEL_SCORES[array_rand($EXCEL_SCORES)];
  80. }
  81.  
  82.  
  83.  
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement