Site icon R-bloggers

Sampling from shifted Gompertz distribution

[This article was first published on Jakub Glinka's Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
using Accept-Reject method – < svg style="display: none;">< defs id="MathJax_SVG_glyphs">< path stroke-width="1" id="MJMATHI-70" d="M23 287Q24 290 25 295T30 317T40 348T55 381T75 411T101 433T134 442Q209 442 230 378L240 387Q302 442 358 442Q423 442 460 395T497 281Q497 173 421 82T249 -10Q227 -10 210 -4Q199 1 187 11T168 28L161 36Q160 35 139 -51T118 -138Q118 -144 126 -145T163 -148H188Q194 -155 194 -157T191 -175Q188 -187 185 -190T172 -194Q170 -194 161 -194T127 -193T65 -192Q-5 -192 -24 -194H-32Q-39 -187 -39 -183Q-37 -156 -26 -148H-6Q28 -147 33 -136Q36 -130 94 103T155 350Q156 355 156 364Q156 405 131 405Q109 405 94 377T71 316T59 280Q57 278 43 278H29Q23 284 23 287ZM178 102Q200 26 252 26Q282 26 310 49T356 107Q374 141 392 215T411 325V331Q411 405 350 405Q339 405 328 402T306 393T286 380T269 365T254 350T243 336T235 326L232 322Q232 321 229 308T218 264T204 212Q178 106 178 102Z">< path stroke-width="1" id="MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z">< path stroke-width="1" id="MJMATHI-74" d="M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z">< path stroke-width="1" id="MJMAIN-7C" d="M139 -249H137Q125 -249 119 -235V251L120 737Q130 750 139 750Q152 750 159 735V-235Q151 -249 141 -249H139Z">< path stroke-width="1" id="MJMATHI-62" d="M73 647Q73 657 77 670T89 683Q90 683 161 688T234 694Q246 694 246 685T212 542Q204 508 195 472T180 418L176 399Q176 396 182 402Q231 442 283 442Q345 442 383 396T422 280Q422 169 343 79T173 -11Q123 -11 82 27T40 150V159Q40 180 48 217T97 414Q147 611 147 623T109 637Q104 637 101 637H96Q86 637 83 637T76 640T73 647ZM336 325V331Q336 405 275 405Q258 405 240 397T207 376T181 352T163 330L157 322L136 236Q114 150 114 114Q114 66 138 42Q154 26 178 26Q211 26 245 58Q270 81 285 114T318 219Q336 291 336 325Z">< path stroke-width="1" id="MJMAIN-2C" d="M78 35T78 60T94 103T137 121Q165 121 187 96T210 8Q210 -27 201 -60T180 -117T154 -158T130 -185T117 -194Q113 -194 104 -185T95 -172Q95 -168 106 -156T131 -126T157 -76T173 -3V9L172 8Q170 7 167 6T161 3T152 1T140 0Q113 0 96 17Z">< path stroke-width="1" id="MJMATHI-3B7" d="M21 287Q22 290 23 295T28 317T38 348T53 381T73 411T99 433T132 442Q156 442 175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336V326Q503 302 439 53Q381 -182 377 -189Q364 -216 332 -216Q319 -216 310 -208T299 -186Q299 -177 358 57L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 114 189T154 366Q154 405 128 405Q107 405 92 377T68 316T57 280Q55 278 41 278H27Q21 284 21 287Z">< path stroke-width="1" id="MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z">< path stroke-width="1" id="MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z">< path stroke-width="1" id="MJMAIN-65" d="M28 218Q28 273 48 318T98 391T163 433T229 448Q282 448 320 430T378 380T406 316T415 245Q415 238 408 231H126V216Q126 68 226 36Q246 30 270 30Q312 30 342 62Q359 79 369 104L379 128Q382 131 395 131H398Q415 131 415 121Q415 117 412 108Q393 53 349 21T250 -11Q155 -11 92 58T28 218ZM333 275Q322 403 238 411H236Q228 411 220 410T195 402T166 381T143 340T127 274V267H333V275Z">< path stroke-width="1" id="MJMAIN-78" d="M201 0Q189 3 102 3Q26 3 17 0H11V46H25Q48 47 67 52T96 61T121 78T139 96T160 122T180 150L226 210L168 288Q159 301 149 315T133 336T122 351T113 363T107 370T100 376T94 379T88 381T80 383Q74 383 44 385H16V431H23Q59 429 126 429Q219 429 229 431H237V385Q201 381 201 369Q201 367 211 353T239 315T268 274L272 270L297 304Q329 345 329 358Q329 364 327 369T322 376T317 380T310 384L307 385H302V431H309Q324 428 408 428Q487 428 493 431H499V385H492Q443 385 411 368Q394 360 377 341T312 257L296 236L358 151Q424 61 429 57T446 50Q464 46 499 46H516V0H510H502Q494 1 482 1T457 2T432 2T414 3Q403 3 377 3T327 1L304 0H295V46H298Q309 46 320 51T331 63Q331 65 291 120L250 175Q249 174 219 133T185 88Q181 83 181 74Q181 63 188 55T206 46Q208 46 208 23V0H201Z">< path stroke-width="1" id="MJMAIN-70" d="M36 -148H50Q89 -148 97 -134V-126Q97 -119 97 -107T97 -77T98 -38T98 6T98 55T98 106Q98 140 98 177T98 243T98 296T97 335T97 351Q94 370 83 376T38 385H20V408Q20 431 22 431L32 432Q42 433 61 434T98 436Q115 437 135 438T165 441T176 442H179V416L180 390L188 397Q247 441 326 441Q407 441 464 377T522 216Q522 115 457 52T310 -11Q242 -11 190 33L182 40V-45V-101Q182 -128 184 -134T195 -145Q216 -148 244 -148H260V-194H252L228 -193Q205 -192 178 -192T140 -191Q37 -191 28 -194H20V-148H36ZM424 218Q424 292 390 347T305 402Q234 402 182 337V98Q222 26 294 26Q345 26 384 80T424 218Z">< path stroke-width="1" id="MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z">< path stroke-width="1" id="MJMATHI-65" d="M39 168Q39 225 58 272T107 350T174 402T244 433T307 442H310Q355 442 388 420T421 355Q421 265 310 237Q261 224 176 223Q139 223 138 221Q138 219 132 186T125 128Q125 81 146 54T209 26T302 45T394 111Q403 121 406 121Q410 121 419 112T429 98T420 82T390 55T344 24T281 -1T205 -11Q126 -11 83 42T39 168ZM373 353Q367 405 305 405Q272 405 244 391T199 357T170 316T154 280T149 261Q149 260 169 260Q282 260 327 284T373 353Z">< path stroke-width="1" id="MJMAIN-5B" d="M118 -250V750H255V710H158V-210H255V-250H118Z">< path stroke-width="1" id="MJMAIN-31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z">< path stroke-width="1" id="MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370 570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401 -82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z">< path stroke-width="1" id="MJMAIN-5D" d="M22 710V750H159V-250H22V-210H119V710H22Z">< path stroke-width="1" id="MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z">< path stroke-width="1" id="MJMATHI-58" d="M42 0H40Q26 0 26 11Q26 15 29 27Q33 41 36 43T55 46Q141 49 190 98Q200 108 306 224T411 342Q302 620 297 625Q288 636 234 637H206Q200 643 200 645T202 664Q206 677 212 683H226Q260 681 347 681Q380 681 408 681T453 682T473 682Q490 682 490 671Q490 670 488 658Q484 643 481 640T465 637Q434 634 411 620L488 426L541 485Q646 598 646 610Q646 628 622 635Q617 635 609 637Q594 637 594 648Q594 650 596 664Q600 677 606 683H618Q619 683 643 683T697 681T738 680Q828 680 837 683H845Q852 676 852 672Q850 647 840 637H824Q790 636 763 628T722 611T698 593L687 584Q687 585 592 480L505 384Q505 383 536 304T601 142T638 56Q648 47 699 46Q734 46 734 37Q734 35 732 23Q728 7 725 4T711 1Q708 1 678 1T589 2Q528 2 496 2T461 1Q444 1 444 10Q444 11 446 25Q448 35 450 39T455 44T464 46T480 47T506 54Q523 62 523 64Q522 64 476 181L429 299Q241 95 236 84Q232 76 232 72Q232 53 261 47Q262 47 267 47T273 46Q276 46 277 46T280 45T283 42T284 35Q284 26 282 19Q279 6 276 4T261 1Q258 1 243 1T201 2T142 2Q64 2 42 0Z">< path stroke-width="1" id="MJMAIN-223C" d="M55 166Q55 241 101 304T222 367Q260 367 296 349T362 304T421 252T484 208T554 189Q616 189 655 236T694 338Q694 350 698 358T708 367Q722 367 722 334Q722 260 677 197T562 134H554Q517 134 481 152T414 196T355 248T292 293T223 311Q179 311 145 286Q109 257 96 218T80 156T69 133Q55 133 55 166Z">< path stroke-width="1" id="MJMATHI-66" d="M118 -162Q120 -162 124 -164T135 -167T147 -168Q160 -168 171 -155T187 -126Q197 -99 221 27T267 267T289 382V385H242Q195 385 192 387Q188 390 188 397L195 425Q197 430 203 430T250 431Q298 431 298 432Q298 434 307 482T319 540Q356 705 465 705Q502 703 526 683T550 630Q550 594 529 578T487 561Q443 561 443 603Q443 622 454 636T478 657L487 662Q471 668 457 668Q445 668 434 658T419 630Q412 601 403 552T387 469T380 433Q380 431 435 431Q480 431 487 430T498 424Q499 420 496 407T491 391Q489 386 482 386T428 385H372L349 263Q301 15 282 -47Q255 -132 212 -173Q175 -205 139 -205Q107 -205 81 -186T55 -132Q55 -95 76 -78T118 -61Q162 -61 162 -103Q162 -122 151 -136T127 -157L118 -162Z">< path stroke-width="1" id="MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z">< path stroke-width="1" id="MJMATHI-55" d="M107 637Q73 637 71 641Q70 643 70 649Q70 673 81 682Q83 683 98 683Q139 681 234 681Q268 681 297 681T342 682T362 682Q378 682 378 672Q378 670 376 658Q371 641 366 638H364Q362 638 359 638T352 638T343 637T334 637Q295 636 284 634T266 623Q265 621 238 518T184 302T154 169Q152 155 152 140Q152 86 183 55T269 24Q336 24 403 69T501 205L552 406Q599 598 599 606Q599 633 535 637Q511 637 511 648Q511 650 513 660Q517 676 519 679T529 683Q532 683 561 682T645 680Q696 680 723 681T752 682Q767 682 767 672Q767 650 759 642Q756 637 737 637Q666 633 648 597Q646 592 598 404Q557 235 548 205Q515 105 433 42T263 -22Q171 -22 116 34T60 167V183Q60 201 115 421Q164 622 164 628Q164 635 107 637Z">< path stroke-width="1" id="MJAMS-55" d="M16 666Q16 677 28 683H341L348 679Q359 665 348 654Q342 648 315 648Q270 644 266 632Q262 627 262 598T261 399Q261 372 261 325T260 260Q260 149 274 99T339 30Q355 25 393 25Q430 25 457 33T494 49T519 72Q562 115 575 205Q576 219 576 379Q576 538 575 550Q568 597 550 622T506 648Q498 648 493 654T487 667T499 683H697Q709 675 709 667T704 654T690 648Q653 648 633 597Q624 573 622 546T619 377Q617 193 613 174Q596 95 544 41Q477 -19 355 -19H344Q275 -16 226 5T153 57T120 110T106 154Q101 172 99 399Q99 618 95 632Q88 644 53 648Q16 648 16 666ZM228 639L233 648H128Q128 647 133 632Q135 621 135 412Q135 197 137 185Q148 115 181 79Q209 51 235 41Q242 36 258 31T277 25Q276 27 268 38T254 59T241 92T228 145Q226 161 226 399Q226 632 228 639ZM604 621Q606 626 619 648H577L586 634Q587 632 591 625T595 614L597 608L604 621Z">< path stroke-width="1" id="MJMAIN-7B" d="M434 -231Q434 -244 428 -250H410Q281 -250 230 -184Q225 -177 222 -172T217 -161T213 -148T211 -133T210 -111T209 -84T209 -47T209 0Q209 21 209 53Q208 142 204 153Q203 154 203 155Q189 191 153 211T82 231Q71 231 68 234T65 250T68 266T82 269Q116 269 152 289T203 345Q208 356 208 377T209 529V579Q209 634 215 656T244 698Q270 724 324 740Q361 748 377 749Q379 749 390 749T408 750H428Q434 744 434 732Q434 719 431 716Q429 713 415 713Q362 710 332 689T296 647Q291 634 291 499V417Q291 370 288 353T271 314Q240 271 184 255L170 250L184 245Q202 239 220 230T262 196T290 137Q291 131 291 1Q291 -134 296 -147Q306 -174 339 -192T415 -213Q429 -213 431 -216Q434 -219 434 -231Z">< path stroke-width="1" id="MJMATHI-75" d="M21 287Q21 295 30 318T55 370T99 420T158 442Q204 442 227 417T250 358Q250 340 216 246T182 105Q182 62 196 45T238 27T291 44T328 78L339 95Q341 99 377 247Q407 367 413 387T427 416Q444 431 463 431Q480 431 488 421T496 402L420 84Q419 79 419 68Q419 43 426 35T447 26Q469 29 482 57T512 145Q514 153 532 153Q551 153 551 144Q550 139 549 130T540 98T523 55T498 17T462 -8Q454 -10 438 -10Q372 -10 347 46Q345 45 336 36T318 21T296 6T267 -6T233 -11Q189 -11 155 7Q103 38 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z">< path stroke-width="1" id="MJMAIN-3A" d="M78 370Q78 394 95 412T138 430Q162 430 180 414T199 371Q199 346 182 328T139 310T96 327T78 370ZM78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z">< path stroke-width="1" id="MJMAIN-3C" d="M694 -11T694 -19T688 -33T678 -40Q671 -40 524 29T234 166L90 235Q83 240 83 250Q83 261 91 266Q664 540 678 540Q681 540 687 534T694 519T687 505Q686 504 417 376L151 250L417 124Q686 -4 687 -5Q694 -11 694 -19Z">< path stroke-width="1" id="MJMAIN-7D" d="M65 731Q65 745 68 747T88 750Q171 750 216 725T279 670Q288 649 289 635T291 501Q292 362 293 357Q306 312 345 291T417 269Q428 269 431 266T434 250T431 234T417 231Q380 231 345 210T298 157Q293 143 292 121T291 -28V-79Q291 -134 285 -156T256 -198Q202 -250 89 -250Q71 -250 68 -247T65 -230Q65 -224 65 -223T66 -218T69 -214T77 -213Q91 -213 108 -210T146 -200T183 -177T207 -139Q208 -134 209 3L210 139Q223 196 280 230Q315 247 330 250Q305 257 280 270Q225 304 212 352L210 362L209 498Q208 635 207 640Q195 680 154 696T77 713Q68 713 67 716T65 731Z">< path stroke-width="1" id="MJAMS-25A0" d="M71 0Q59 4 55 16V346L56 676Q64 686 70 689H709Q719 681 722 674V15Q719 10 709 1L390 0H71Z">< path stroke-width="1" id="MJMATHI-67" d="M311 43Q296 30 267 15T206 0Q143 0 105 45T66 160Q66 265 143 353T314 442Q361 442 401 394L404 398Q406 401 409 404T418 412T431 419T447 422Q461 422 470 413T480 394Q480 379 423 152T363 -80Q345 -134 286 -169T151 -205Q10 -205 10 -137Q10 -111 28 -91T74 -71Q89 -71 102 -80T116 -111Q116 -121 114 -130T107 -144T99 -154T92 -162L90 -164H91Q101 -167 151 -167Q189 -167 211 -155Q234 -144 254 -122T282 -75Q288 -56 298 -13Q311 35 311 43ZM384 328L380 339Q377 350 375 354T369 368T359 382T346 393T328 402T306 405Q262 405 221 352Q191 313 171 233T151 117Q151 38 213 38Q269 38 323 108L331 118L384 328Z">< path stroke-width="1" id="MJMAIN-2264" d="M674 636Q682 636 688 630T694 615T687 601Q686 600 417 472L151 346L399 228Q687 92 691 87Q694 81 694 76Q694 58 676 56H670L382 192Q92 329 90 331Q83 336 83 348Q84 359 96 365Q104 369 382 500T665 634Q669 636 674 636ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z">< path stroke-width="1" id="MJMATHI-4D" d="M289 629Q289 635 232 637Q208 637 201 638T194 648Q194 649 196 659Q197 662 198 666T199 671T201 676T203 679T207 681T212 683T220 683T232 684Q238 684 262 684T307 683Q386 683 398 683T414 678Q415 674 451 396L487 117L510 154Q534 190 574 254T662 394Q837 673 839 675Q840 676 842 678T846 681L852 683H948Q965 683 988 683T1017 684Q1051 684 1051 673Q1051 668 1048 656T1045 643Q1041 637 1008 637Q968 636 957 634T939 623Q936 618 867 340T797 59Q797 55 798 54T805 50T822 48T855 46H886Q892 37 892 35Q892 19 885 5Q880 0 869 0Q864 0 828 1T736 2Q675 2 644 2T609 1Q592 1 592 11Q592 13 594 25Q598 41 602 43T625 46Q652 46 685 49Q699 52 704 61Q706 65 742 207T813 490T848 631L654 322Q458 10 453 5Q451 4 449 3Q444 0 433 0Q418 0 415 7Q413 11 374 317L335 624L267 354Q200 88 200 79Q206 46 272 46H282Q288 41 289 37T286 19Q282 3 278 1Q274 0 267 0Q265 0 255 0T221 1T157 2Q127 2 95 1T58 0Q43 0 39 2T35 11Q35 13 38 25T43 40Q45 46 65 46Q135 46 154 86Q158 92 223 354T289 629Z">< path stroke-width="1" id="MJMAIN-2265" d="M83 616Q83 624 89 630T99 636Q107 636 253 568T543 431T687 361Q694 356 694 346T687 331Q685 329 395 192L107 56H101Q83 58 83 76Q83 77 83 79Q82 86 98 95Q117 105 248 167Q326 204 378 228L626 346L360 472Q291 505 200 548Q112 589 98 597T83 616ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z">< path stroke-width="1" id="MJMATHI-68" d="M137 683Q138 683 209 688T282 694Q294 694 294 685Q294 674 258 534Q220 386 220 383Q220 381 227 388Q288 442 357 442Q411 442 444 415T478 336Q478 285 440 178T402 50Q403 36 407 31T422 26Q450 26 474 56T513 138Q516 149 519 151T535 153Q555 153 555 145Q555 144 551 130Q535 71 500 33Q466 -10 419 -10H414Q367 -10 346 17T325 74Q325 90 361 192T398 345Q398 404 354 404H349Q266 404 205 306L198 293L164 158Q132 28 127 16Q114 -11 83 -11Q69 -11 59 -2T48 16Q48 30 121 320L195 616Q195 629 188 632T149 637H128Q122 643 122 645T124 664Q129 683 137 683Z">< path stroke-width="1" id="MJMATHI-59" d="M66 637Q54 637 49 637T39 638T32 641T30 647T33 664T42 682Q44 683 56 683Q104 680 165 680Q288 680 306 683H316Q322 677 322 674T320 656Q316 643 310 637H298Q242 637 242 624Q242 619 292 477T343 333L346 336Q350 340 358 349T379 373T411 410T454 461Q546 568 561 587T577 618Q577 634 545 637Q528 637 528 647Q528 649 530 661Q533 676 535 679T549 683Q551 683 578 682T657 680Q684 680 713 681T746 682Q763 682 763 673Q763 669 760 657T755 643Q753 637 734 637Q662 632 617 587Q608 578 477 424L348 273L322 169Q295 62 295 57Q295 46 363 46Q379 46 384 45T390 35Q390 33 388 23Q384 6 382 4T366 1Q361 1 324 1T232 2Q170 2 138 2T102 1Q84 1 84 9Q84 14 87 24Q88 27 89 30T90 35T91 39T93 42T96 44T101 45T107 45T116 46T129 46Q168 47 180 50T198 63Q201 68 227 171L252 274L129 623Q128 624 127 625T125 627T122 629T118 631T113 633T105 634T96 635T83 636T66 637Z">< path stroke-width="1" id="MJMATHI-61" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z">< path stroke-width="1" id="MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z">< path stroke-width="1" id="MJMATHI-64" d="M366 683Q367 683 438 688T511 694Q523 694 523 686Q523 679 450 384T375 83T374 68Q374 26 402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487H491Q506 153 506 145Q506 140 503 129Q490 79 473 48T445 8T417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157Q33 205 53 255T101 341Q148 398 195 420T280 442Q336 442 364 400Q369 394 369 396Q370 400 396 505T424 616Q424 629 417 632T378 637H357Q351 643 351 645T353 664Q358 683 366 683ZM352 326Q329 405 277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q233 26 290 98L298 109L352 326Z">< path stroke-width="1" id="MJMATHI-79" d="M21 287Q21 301 36 335T84 406T158 442Q199 442 224 419T250 355Q248 336 247 334Q247 331 231 288T198 191T182 105Q182 62 196 45T238 27Q261 27 281 38T312 61T339 94Q339 95 344 114T358 173T377 247Q415 397 419 404Q432 431 462 431Q475 431 483 424T494 412T496 403Q496 390 447 193T391 -23Q363 -106 294 -155T156 -205Q111 -205 77 -183T43 -117Q43 -95 50 -80T69 -58T89 -48T106 -45Q150 -45 150 -87Q150 -107 138 -122T115 -142T102 -147L99 -148Q101 -153 118 -160T152 -167H160Q177 -167 186 -165Q219 -156 247 -127T290 -65T313 -9T321 21L315 17Q309 13 296 6T270 -6Q250 -11 231 -11Q185 -11 150 11T104 82Q103 89 103 113Q103 170 138 262T173 379Q173 380 173 381Q173 390 173 393T169 400T158 404H154Q131 404 112 385T82 344T65 302T57 280Q55 278 41 278H27Q21 284 21 287Z">< path stroke-width="1" id="MJMAIN-2E" d="M78 60Q78 84 95 102T138 120Q162 120 180 104T199 61Q199 36 182 18T139 0T96 17T78 60Z">< path stroke-width="1" id="MJMAIN-34" d="M462 0Q444 3 333 3Q217 3 199 0H190V46H221Q241 46 248 46T265 48T279 53T286 61Q287 63 287 115V165H28V211L179 442Q332 674 334 675Q336 677 355 677H373L379 671V211H471V165H379V114Q379 73 379 66T385 54Q393 47 442 46H471V0H462ZM293 211V545L74 212L183 211H293Z">< path stroke-width="1" id="MJMAIN-2200" d="M0 673Q0 684 7 689T20 694Q32 694 38 680T82 567L126 451H430L473 566Q483 593 494 622T512 668T519 685Q524 694 538 694Q556 692 556 674Q556 670 426 329T293 -15Q288 -22 278 -22T263 -15Q260 -11 131 328T0 673ZM414 410Q414 411 278 411T142 410L278 55L414 410Z">< path stroke-width="1" id="MJMAIN-3E" d="M84 520Q84 528 88 533T96 539L99 540Q106 540 253 471T544 334L687 265Q694 260 694 250T687 235Q685 233 395 96L107 -40H101Q83 -38 83 -20Q83 -19 83 -17Q82 -10 98 -1Q117 9 248 71Q326 108 378 132L626 250L378 368Q90 504 86 509Q84 513 84 520Z">< path stroke-width="1" id="MJMAIN-2032" d="M79 43Q73 43 52 49T30 61Q30 68 85 293T146 528Q161 560 198 560Q218 560 240 545T262 501Q262 496 260 486Q259 479 173 263T84 45T79 43Z">< path stroke-width="1" id="MJMAIN-2217" d="M229 286Q216 420 216 436Q216 454 240 464Q241 464 245 464T251 465Q263 464 273 456T283 436Q283 419 277 356T270 286L328 328Q384 369 389 372T399 375Q412 375 423 365T435 338Q435 325 425 315Q420 312 357 282T289 250L355 219L425 184Q434 175 434 161Q434 146 425 136T401 125Q393 125 383 131T328 171L270 213Q283 79 283 63Q283 53 276 44T250 35Q231 35 224 44T216 63Q216 80 222 143T229 213L171 171Q115 130 110 127Q106 124 100 124Q87 124 76 134T64 161Q64 166 64 169T67 175T72 181T81 188T94 195T113 204T138 215T170 230T210 250L74 315Q65 324 65 338Q65 353 74 363T98 374Q106 374 116 368T171 328L229 286Z">< path stroke-width="1" id="MJMATHI-6D" d="M21 287Q22 293 24 303T36 341T56 388T88 425T132 442T175 435T205 417T221 395T229 376L231 369Q231 367 232 367L243 378Q303 442 384 442Q401 442 415 440T441 433T460 423T475 411T485 398T493 385T497 373T500 364T502 357L510 367Q573 442 659 442Q713 442 746 415T780 336Q780 285 742 178T704 50Q705 36 709 31T724 26Q752 26 776 56T815 138Q818 149 821 151T837 153Q857 153 857 145Q857 144 853 130Q845 101 831 73T785 17T716 -10Q669 -10 648 17T627 73Q627 92 663 193T700 345Q700 404 656 404H651Q565 404 506 303L499 291L466 157Q433 26 428 16Q415 -11 385 -11Q372 -11 364 -4T353 8T350 18Q350 29 384 161L420 307Q423 322 423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 181Q151 335 151 342Q154 357 154 369Q154 405 129 405Q107 405 92 377T69 316T57 280Q55 278 41 278H27Q21 284 21 287Z">< path stroke-width="1" id="MJMAIN-221E" d="M55 217Q55 305 111 373T254 442Q342 442 419 381Q457 350 493 303L507 284L514 294Q618 442 747 442Q833 442 888 374T944 214Q944 128 889 59T743 -11Q657 -11 580 50Q542 81 506 128L492 147L485 137Q381 -11 252 -11Q166 -11 111 57T55 217ZM907 217Q907 285 869 341T761 397Q740 397 720 392T682 378T648 359T619 335T594 310T574 285T559 263T548 246L543 238L574 198Q605 158 622 138T664 94T714 61T765 51Q827 51 867 100T907 217ZM92 214Q92 145 131 89T239 33Q357 33 456 193L425 233Q364 312 334 337Q285 380 233 380Q171 380 132 331T92 214Z">< path stroke-width="1" id="MJSZ1-222B" d="M113 -244Q113 -246 119 -251T139 -263T167 -269Q186 -269 199 -260Q220 -247 232 -218T251 -133T262 -15T276 155T297 367Q300 390 305 438T314 512T325 580T340 647T361 703T390 751T428 784T479 804Q481 804 488 804T501 805Q552 802 581 769T610 695Q610 669 594 657T561 645Q542 645 527 658T512 694Q512 705 516 714T526 729T538 737T548 742L552 743Q552 745 545 751T525 762T498 768Q475 768 460 756T434 716T418 652T407 559T398 444T387 300T369 133Q349 -38 337 -102T303 -207Q256 -306 169 -306Q119 -306 87 -272T55 -196Q55 -170 71 -158T104 -146Q123 -146 138 -159T153 -195Q153 -206 149 -215T139 -230T127 -238T117 -242L113 -244Z">< path stroke-width="1" id="MJMATHI-73" d="M131 289Q131 321 147 354T203 415T300 442Q362 442 390 415T419 355Q419 323 402 308T364 292Q351 292 340 300T328 326Q328 342 337 354T354 372T367 378Q368 378 368 379Q368 382 361 388T336 399T297 405Q249 405 227 379T204 326Q204 301 223 291T278 274T330 259Q396 230 396 163Q396 135 385 107T352 51T289 7T195 -10Q118 -10 86 19T53 87Q53 126 74 143T118 160Q133 160 146 151T160 120Q160 94 142 76T111 58Q109 57 108 57T107 55Q108 52 115 47T146 34T201 27Q237 27 263 38T301 66T318 97T323 122Q323 150 302 164T254 181T195 196T148 231Q131 256 131 289Z">< path stroke-width="1" id="MJMAIN-64" d="M376 495Q376 511 376 535T377 568Q377 613 367 624T316 637H298V660Q298 683 300 683L310 684Q320 685 339 686T376 688Q393 689 413 690T443 693T454 694H457V390Q457 84 458 81Q461 61 472 55T517 46H535V0Q533 0 459 -5T380 -11H373V44L365 37Q307 -11 235 -11Q158 -11 96 50T34 215Q34 315 97 378T244 442Q319 442 376 393V495ZM373 342Q328 405 260 405Q211 405 173 369Q146 341 139 305T131 211Q131 155 138 120T173 59Q203 26 251 26Q322 26 373 103V342Z">< path stroke-width="1" id="MJSZ1-7B" d="M477 -343L471 -349H458Q432 -349 367 -325T273 -263Q258 -245 250 -212L249 -51Q249 -27 249 12Q248 118 244 128Q243 129 243 130Q220 189 121 228Q109 232 107 235T105 250Q105 256 105 257T105 261T107 265T111 268T118 272T128 276T142 283T162 291Q224 324 243 371Q243 372 244 373Q248 384 249 469Q249 475 249 489Q249 528 249 552L250 714Q253 728 256 736T271 761T299 789T347 816T422 843Q440 849 441 849H443Q445 849 447 849T452 850T457 850H471L477 844V830Q477 820 476 817T470 811T459 807T437 801T404 785Q353 760 338 724Q333 710 333 550Q333 526 333 492T334 447Q334 393 327 368T295 318Q257 280 181 255L169 251L184 245Q318 198 332 112Q333 106 333 -49Q333 -209 338 -223Q351 -255 391 -277T469 -309Q477 -311 477 -329V-343Z">< path stroke-width="1" id="MJSZ1-7D" d="M110 849L115 850Q120 850 125 850Q151 850 215 826T309 764Q324 747 332 714L333 552Q333 528 333 489Q334 383 338 373Q339 372 339 371Q353 336 391 310T469 271Q477 268 477 251Q477 241 476 237T472 232T456 225T428 214Q357 179 339 130Q339 129 338 128Q334 117 333 32Q333 26 333 12Q333 -27 333 -51L332 -212Q328 -228 323 -240T302 -271T255 -307T175 -338Q139 -349 125 -349T108 -346T105 -329Q105 -314 107 -312T130 -304Q233 -271 248 -209Q249 -203 249 -49V57Q249 106 253 125T273 167Q307 213 398 245L413 251L401 255Q265 300 250 389Q249 395 249 550Q249 710 244 724Q224 774 112 811Q105 813 105 830Q105 845 110 849Z">< path stroke-width="1" id="MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z">< path stroke-width="1" id="MJMAIN-45" d="M128 619Q121 626 117 628T101 631T58 634H25V680H597V676Q599 670 611 560T625 444V440H585V444Q584 447 582 465Q578 500 570 526T553 571T528 601T498 619T457 629T411 633T353 634Q266 634 251 633T233 622Q233 622 233 621Q232 619 232 497V376H286Q359 378 377 385Q413 401 416 469Q416 471 416 473V493H456V213H416V233Q415 268 408 288T383 317T349 328T297 330Q290 330 286 330H232V196V114Q232 57 237 52Q243 47 289 47H340H391Q428 47 452 50T505 62T552 92T584 146Q594 172 599 200T607 247T612 270V273H652V270Q651 267 632 137T610 3V0H25V46H58Q100 47 109 49T128 61V619Z">

Shifted Gompertz distribution

Shifted Gompertz distribution is useful distribution which can be used to describe time needed for adopting new innovation within the market. Recent studies showed that it outperforms Bass model of diffusion in some cases1.

Its pdf is given by

< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="55.15ex" height="3.176ex" style="vertical-align: -0.838ex;" viewBox="-38.5 -1006.6 23745.2 1367.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-70">< use x="503" y="0" xlink:href="#MJMAIN-28">< use x="893" y="0" xlink:href="#MJMATHI-74">< use x="1254" y="0" xlink:href="#MJMAIN-7C">< use x="1533" y="0" xlink:href="#MJMATHI-62">< use x="1962" y="0" xlink:href="#MJMAIN-2C">< use x="2407" y="0" xlink:href="#MJMATHI-3B7">< use x="2911" y="0" xlink:href="#MJMAIN-29">< use x="3578" y="0" xlink:href="#MJMAIN-3D">< use x="4634" y="0" xlink:href="#MJMATHI-62">< g transform="translate(5230,0)">< use xlink:href="#MJMAIN-65">< use x="444" y="0" xlink:href="#MJMAIN-78">< use x="973" y="0" xlink:href="#MJMAIN-70">< use x="6760" y="0" xlink:href="#MJMAIN-28">< use x="7149" y="0" xlink:href="#MJMAIN-2212">< use x="7928" y="0" xlink:href="#MJMATHI-62">< use x="8357" y="0" xlink:href="#MJMATHI-74">< use x="8719" y="0" xlink:href="#MJMAIN-29">< g transform="translate(9275,0)">< use xlink:href="#MJMAIN-65">< use x="444" y="0" xlink:href="#MJMAIN-78">< use x="973" y="0" xlink:href="#MJMAIN-70">< use x="10805" y="0" xlink:href="#MJMAIN-28">< use x="11194" y="0" xlink:href="#MJMAIN-2212">< use x="11973" y="0" xlink:href="#MJMATHI-3B7">< g transform="translate(12476,0)">< use x="0" y="0" xlink:href="#MJMATHI-65">< g transform="translate(466,412)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-2212">< use transform="scale(0.707)" x="778" y="0" xlink:href="#MJMATHI-62">< use transform="scale(0.707)" x="1208" y="0" xlink:href="#MJMATHI-74">< use x="14152" y="0" xlink:href="#MJMAIN-29">< use x="14542" y="0" xlink:href="#MJMAIN-5B">< use x="14820" y="0" xlink:href="#MJMAIN-31">< use x="15543" y="0" xlink:href="#MJMAIN-2B">< use x="16544" y="0" xlink:href="#MJMATHI-3B7">< use x="17047" y="0" xlink:href="#MJMAIN-28">< use x="17437" y="0" xlink:href="#MJMAIN-31">< use x="18160" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(19160,0)">< use xlink:href="#MJMAIN-65">< use x="444" y="0" xlink:href="#MJMAIN-78">< use x="973" y="0" xlink:href="#MJMAIN-70">< use x="20690" y="0" xlink:href="#MJMAIN-28">< use x="21079" y="0" xlink:href="#MJMAIN-2212">< use x="21858" y="0" xlink:href="#MJMATHI-62">< use x="22287" y="0" xlink:href="#MJMATHI-74">< use x="22649" y="0" xlink:href="#MJMAIN-29">< use x="23038" y="0" xlink:href="#MJMAIN-29">< use x="23428" y="0" xlink:href="#MJMAIN-5D">

Below we show what happens if we increase < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.169ex" height="2.176ex" style="vertical-align: -0.838ex;" viewBox="0 -576.1 503.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3B7"> parameter (inverse of propensity to adopt) for different values of < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="0.998ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 429.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-62"> appeal of innovation. Higher < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.169ex" height="2.176ex" style="vertical-align: -0.838ex;" viewBox="0 -576.1 503.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-3B7"> parameter is set more density mode is shifted away from < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.162ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 500.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-30">.

This distribution do not have closed form solutions for moments. If we want to calculate them and also simulate data for model validation we need to be able to sample from it. Luckily there is a simple way of producing samples from arbitrary density:

Fundamental Theorem of Simulation.
Simulating

< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="9.496ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 4088.6 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use x="1130" y="0" xlink:href="#MJMAIN-223C">< use x="2186" y="0" xlink:href="#MJMATHI-66">< use x="2737" y="0" xlink:href="#MJMAIN-28">< use x="3126" y="0" xlink:href="#MJMATHI-78">< use x="3699" y="0" xlink:href="#MJMAIN-29">

is equivalent to simulating

< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="38.384ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 16526.6 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-28">< use x="389" y="0" xlink:href="#MJMATHI-58">< use x="1242" y="0" xlink:href="#MJMAIN-2C">< use x="1687" y="0" xlink:href="#MJMATHI-55">< use x="2454" y="0" xlink:href="#MJMAIN-29">< use x="3121" y="0" xlink:href="#MJMAIN-223C">< use x="4178" y="0" xlink:href="#MJAMS-55">< use x="4900" y="0" xlink:href="#MJMAIN-7B">< use x="5401" y="0" xlink:href="#MJMAIN-28">< use x="5790" y="0" xlink:href="#MJMATHI-78">< use x="6363" y="0" xlink:href="#MJMAIN-2C">< use x="6808" y="0" xlink:href="#MJMATHI-75">< use x="7380" y="0" xlink:href="#MJMAIN-29">< use x="8048" y="0" xlink:href="#MJMAIN-3A">< use x="8604" y="0" xlink:href="#MJMAIN-30">< use x="9382" y="0" xlink:href="#MJMAIN-3C">< use x="10439" y="0" xlink:href="#MJMATHI-75">< use x="11289" y="0" xlink:href="#MJMAIN-3C">< use x="12345" y="0" xlink:href="#MJMATHI-66">< use x="12896" y="0" xlink:href="#MJMAIN-28">< use x="13285" y="0" xlink:href="#MJMATHI-78">< use x="13858" y="0" xlink:href="#MJMAIN-29">< use x="14247" y="0" xlink:href="#MJMAIN-7D">< use x="15748" y="0" xlink:href="#MJAMS-25A0">

Direct corollary introduces convenient way of simulating from target distribution:

Accept-Reject algorithm.
Let < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="9.496ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 4088.6 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use x="1130" y="0" xlink:href="#MJMAIN-223C">< use x="2186" y="0" xlink:href="#MJMATHI-66">< use x="2737" y="0" xlink:href="#MJMAIN-28">< use x="3126" y="0" xlink:href="#MJMATHI-78">< use x="3699" y="0" xlink:href="#MJMAIN-29"> and let < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="4.255ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 1832 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-67">< use x="480" y="0" xlink:href="#MJMAIN-28">< use x="870" y="0" xlink:href="#MJMATHI-78">< use x="1442" y="0" xlink:href="#MJMAIN-29"> be a density function that satisfies < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="14.213ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 6119.6 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-66">< use x="550" y="0" xlink:href="#MJMAIN-28">< use x="940" y="0" xlink:href="#MJMATHI-78">< use x="1512" y="0" xlink:href="#MJMAIN-29">< use x="2179" y="0" xlink:href="#MJMAIN-2264">< use x="3236" y="0" xlink:href="#MJMATHI-4D">< use x="4287" y="0" xlink:href="#MJMATHI-67">< use x="4768" y="0" xlink:href="#MJMAIN-28">< use x="5157" y="0" xlink:href="#MJMATHI-78">< use x="5730" y="0" xlink:href="#MJMAIN-29"> for some constant < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="6.703ex" height="2.343ex" style="vertical-align: -0.505ex;" viewBox="0 -791.3 2886.1 1008.6" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-4D">< use x="1329" y="0" xlink:href="#MJMAIN-2265">< use x="2385" y="0" xlink:href="#MJMAIN-31"> and < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="8.642ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 3721.1 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-68">< g transform="translate(854,0)">< use xlink:href="#MJMAIN-3A">< use x="278" y="0" xlink:href="#MJMAIN-3D">< use x="2189" y="0" xlink:href="#MJMATHI-4D">< use x="3240" y="0" xlink:href="#MJMATHI-67">. Then, to simulate < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="6.357ex" height="2.509ex" style="vertical-align: -0.671ex;" viewBox="0 -791.3 2737.1 1080.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-58">< use x="1130" y="0" xlink:href="#MJMAIN-223C">< use x="2186" y="0" xlink:href="#MJMATHI-66"> it is sufficient to generate pair

< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="37.957ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 16342.3 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-59">< use x="1041" y="0" xlink:href="#MJMAIN-223C">< use x="2097" y="0" xlink:href="#MJMATHI-67">< use x="3578" y="0" xlink:href="#MJMATHI-61">< use x="4107" y="0" xlink:href="#MJMATHI-6E">< use x="4708" y="0" xlink:href="#MJMATHI-64">< use x="6231" y="0" xlink:href="#MJMAIN-28">< use x="6621" y="0" xlink:href="#MJMATHI-55">< use x="7388" y="0" xlink:href="#MJMAIN-7C">< use x="7667" y="0" xlink:href="#MJMATHI-59">< use x="8708" y="0" xlink:href="#MJMAIN-3D">< use x="9764" y="0" xlink:href="#MJMATHI-79">< use x="10262" y="0" xlink:href="#MJMAIN-29">< use x="10929" y="0" xlink:href="#MJMAIN-223C">< use x="11985" y="0" xlink:href="#MJAMS-55">< use x="12708" y="0" xlink:href="#MJMAIN-5B">< use x="12986" y="0" xlink:href="#MJMAIN-30">< use x="13487" y="0" xlink:href="#MJMAIN-2C">< use x="13932" y="0" xlink:href="#MJMATHI-68">< use x="14508" y="0" xlink:href="#MJMAIN-28">< use x="14898" y="0" xlink:href="#MJMATHI-79">< use x="15395" y="0" xlink:href="#MJMAIN-29">< use x="15785" y="0" xlink:href="#MJMAIN-5D">< use x="16063" y="0" xlink:href="#MJMAIN-2C">

until < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="13.753ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 5921.6 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-30">< use x="778" y="0" xlink:href="#MJMAIN-3C">< use x="1834" y="0" xlink:href="#MJMATHI-75">< use x="2684" y="0" xlink:href="#MJMAIN-3C">< use x="3741" y="0" xlink:href="#MJMATHI-66">< use x="4291" y="0" xlink:href="#MJMAIN-28">< use x="4681" y="0" xlink:href="#MJMATHI-78">< use x="5253" y="0" xlink:href="#MJMAIN-29">< use x="5643" y="0" xlink:href="#MJMAIN-2E"> < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="5.292ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 2278.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="1500" y="0" xlink:href="#MJAMS-25A0">

Function < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.339ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 576.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-68"> is sometimes called envelope function. More tight the inequality the more efficient sampling will be.

Simulating from Shifted Gumbel distribution

Let’s assume for a moment that our density has bounded support. Below we plot an example of using Accept-Reject method for sampling from target density with simple constant envelope function:

This way of simulating distribution works but is not particularly efficient as more than 75% of sample is rejected and that’s with assumption that the support of target density is in < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="6.331ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 2725.7 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-28">< use x="389" y="0" xlink:href="#MJMAIN-30">< use x="890" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(1335,0)">< use xlink:href="#MJMAIN-34">< use x="500" y="0" xlink:href="#MJMAIN-30">< use x="2336" y="0" xlink:href="#MJMAIN-29">. If we would extend support of the target density to further away from < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.162ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 500.5 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-30"> we would see increasing drop of sampler efficiency.

We can easily improve our sampling method by noticing the following inequality:

< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="40.089ex" height="2.843ex" style="vertical-align: -0.838ex;" viewBox="0 -863.1 17260.4 1223.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-2200">< g transform="translate(556,-150)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="361" y="0" xlink:href="#MJMAIN-3E">< use transform="scale(0.707)" x="1140" y="0" xlink:href="#MJMAIN-30">< use x="2316" y="0" xlink:href="#MJMATHI-70">< use x="2820" y="0" xlink:href="#MJMAIN-5B">< use x="3098" y="0" xlink:href="#MJMATHI-74">< use x="3460" y="0" xlink:href="#MJMAIN-7C">< use x="3738" y="0" xlink:href="#MJMATHI-62">< use x="4168" y="0" xlink:href="#MJMAIN-2C">< use x="4613" y="0" xlink:href="#MJMATHI-3B7">< use x="5116" y="0" xlink:href="#MJMAIN-5D">< use x="5672" y="0" xlink:href="#MJMAIN-2264">< use x="6729" y="0" xlink:href="#MJMAIN-28">< use x="7118" y="0" xlink:href="#MJMAIN-31">< use x="7841" y="0" xlink:href="#MJMAIN-2B">< use x="8842" y="0" xlink:href="#MJMATHI-3B7">< use x="9345" y="0" xlink:href="#MJMAIN-29">< use x="9735" y="0" xlink:href="#MJMATHI-62">< g transform="translate(10331,0)">< use xlink:href="#MJMAIN-65">< use x="444" y="0" xlink:href="#MJMAIN-78">< use x="973" y="0" xlink:href="#MJMAIN-70">< use x="11860" y="0" xlink:href="#MJMAIN-28">< use x="12250" y="0" xlink:href="#MJMAIN-2212">< use x="13028" y="0" xlink:href="#MJMATHI-62">< use x="13458" y="0" xlink:href="#MJMATHI-74">< use x="13819" y="0" xlink:href="#MJMAIN-29">< use x="14487" y="0" xlink:href="#MJMAIN-3D">< use x="15543" y="0" xlink:href="#MJMATHI-68">< use x="16119" y="0" xlink:href="#MJMAIN-28">< use x="16509" y="0" xlink:href="#MJMATHI-74">< use x="16870" y="0" xlink:href="#MJMAIN-29">

This will provide us nice majorization function for the tail of shifted Gompertz distribution by scaled exponential density.

In order to make it more tight around mode of our target density we can define improved envelope function as:

< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="54.112ex" height="3.343ex" style="vertical-align: -1.171ex;" viewBox="0 -934.9 23298.1 1439.2" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-68">< use transform="scale(0.707)" x="815" y="583" xlink:href="#MJMAIN-2032">< use x="871" y="0" xlink:href="#MJMAIN-28">< use x="1260" y="0" xlink:href="#MJMATHI-74">< use x="1622" y="0" xlink:href="#MJMAIN-29">< use x="2289" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(3345,0)">< use x="0" y="0" xlink:href="#MJMAIN-31">< g transform="translate(500,-187)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-5B">< use transform="scale(0.707)" x="278" y="0" xlink:href="#MJMAIN-30">< use transform="scale(0.707)" x="779" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(747,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="386" xlink:href="#MJMAIN-2217">< use transform="scale(0.707)" x="1925" y="0" xlink:href="#MJMAIN-5D">< use x="5726" y="0" xlink:href="#MJMAIN-2217">< use x="6449" y="0" xlink:href="#MJMATHI-6D">< use x="7328" y="0" xlink:href="#MJMAIN-28">< use x="7717" y="0" xlink:href="#MJMATHI-62">< use x="8147" y="0" xlink:href="#MJMAIN-2C">< use x="8592" y="0" xlink:href="#MJMATHI-3B7">< use x="9095" y="0" xlink:href="#MJMAIN-29">< use x="9707" y="0" xlink:href="#MJMAIN-2B">< g transform="translate(10708,0)">< use x="0" y="0" xlink:href="#MJMAIN-31">< g transform="translate(500,-187)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-28">< g transform="translate(275,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="386" xlink:href="#MJMAIN-2217">< use transform="scale(0.707)" x="1257" y="0" xlink:href="#MJMAIN-2C">< use transform="scale(0.707)" x="1535" y="0" xlink:href="#MJMAIN-2B">< use transform="scale(0.707)" x="2314" y="0" xlink:href="#MJMAIN-221E">< use transform="scale(0.707)" x="3314" y="0" xlink:href="#MJMAIN-29">< use x="14150" y="0" xlink:href="#MJMAIN-2217">< use x="14873" y="0" xlink:href="#MJMAIN-28">< use x="15262" y="0" xlink:href="#MJMAIN-31">< use x="15985" y="0" xlink:href="#MJMAIN-2B">< use x="16986" y="0" xlink:href="#MJMATHI-3B7">< use x="17489" y="0" xlink:href="#MJMAIN-29">< use x="18101" y="0" xlink:href="#MJMAIN-2217">< use x="18823" y="0" xlink:href="#MJMATHI-62">< g transform="translate(19420,0)">< use xlink:href="#MJMAIN-65">< use x="444" y="0" xlink:href="#MJMAIN-78">< use x="973" y="0" xlink:href="#MJMAIN-70">< use x="20949" y="0" xlink:href="#MJMAIN-28">< use x="21339" y="0" xlink:href="#MJMAIN-2212">< use x="22117" y="0" xlink:href="#MJMATHI-62">< use x="22547" y="0" xlink:href="#MJMATHI-74">< use x="22908" y="0" xlink:href="#MJMAIN-29">

where < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.894ex" height="2.176ex" style="vertical-align: -0.338ex;" viewBox="0 -791.3 815.4 936.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="511" y="513" xlink:href="#MJMAIN-2217"> is a point where envelope function reaches maximum of shifted Gompertz density and < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.04ex" height="1.676ex" style="vertical-align: -0.338ex;" viewBox="0 -576.1 878.5 721.6" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-6D"> is a value of the density at this point.

Of course < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="2.024ex" height="2.343ex" style="vertical-align: -0.338ex;" viewBox="0 -863.1 871.3 1008.6" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-68">< use transform="scale(0.707)" x="815" y="513" xlink:href="#MJMAIN-2032"> is not a density itself. Since it is integrable we can recover density < svg xmlns:xlink="http://www.w3.org/1999/xlink" width="1.116ex" height="2.009ex" style="vertical-align: -0.671ex;" viewBox="0 -576.1 480.5 865.1" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-67"> as

< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="47.032ex" height="7.009ex" style="vertical-align: -3.171ex;" viewBox="0 -1652.5 20250 3017.9" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMATHI-67">< use x="480" y="0" xlink:href="#MJMAIN-28">< use x="870" y="0" xlink:href="#MJMATHI-74">< use x="1231" y="0" xlink:href="#MJMAIN-7C">< use x="1510" y="0" xlink:href="#MJMATHI-62">< use x="1939" y="0" xlink:href="#MJMAIN-2C">< use x="2384" y="0" xlink:href="#MJMATHI-3B7">< use x="2888" y="0" xlink:href="#MJMAIN-29">< g transform="translate(3555,0)">< use xlink:href="#MJMAIN-3A">< use x="278" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(4612,0)">< g transform="translate(397,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(1440,770)">< use x="0" y="0" xlink:href="#MJMATHI-68">< use transform="scale(0.707)" x="815" y="513" xlink:href="#MJMAIN-2032">< use x="871" y="0" xlink:href="#MJMAIN-28">< use x="1260" y="0" xlink:href="#MJMATHI-74">< use x="1622" y="0" xlink:href="#MJMAIN-7C">< use x="1900" y="0" xlink:href="#MJMATHI-62">< use x="2330" y="0" xlink:href="#MJMAIN-2C">< use x="2775" y="0" xlink:href="#MJMATHI-3B7">< use x="3278" y="0" xlink:href="#MJMAIN-29">< g transform="translate(60,-867)">< use x="0" y="0" xlink:href="#MJSZ1-222B">< use transform="scale(0.707)" x="921" y="754" xlink:href="#MJMAIN-221E">< use transform="scale(0.707)" x="668" y="-484" xlink:href="#MJMAIN-30">< g transform="translate(1626,0)">< use x="0" y="0" xlink:href="#MJMATHI-68">< use transform="scale(0.707)" x="815" y="408" xlink:href="#MJMAIN-2032">< use x="2497" y="0" xlink:href="#MJMAIN-28">< use x="2886" y="0" xlink:href="#MJMATHI-73">< use x="3356" y="0" xlink:href="#MJMAIN-7C">< use x="3634" y="0" xlink:href="#MJMATHI-62">< use x="4064" y="0" xlink:href="#MJMAIN-2C">< use x="4509" y="0" xlink:href="#MJMATHI-3B7">< use x="5013" y="0" xlink:href="#MJMAIN-29">< use x="5402" y="0" xlink:href="#MJMAIN-64">< use x="5959" y="0" xlink:href="#MJMATHI-73">< use x="11956" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(12735,0)">< g transform="translate(397,0)">< rect stroke="none" width="450" x="0" y="220">< use x="1414" y="676" xlink:href="#MJMAIN-31">< g transform="translate(60,-771)">< use x="0" y="0" xlink:href="#MJMATHI-4D">< use x="1051" y="0" xlink:href="#MJMAIN-28">< use x="1441" y="0" xlink:href="#MJMATHI-62">< use x="1870" y="0" xlink:href="#MJMAIN-2C">< use x="2315" y="0" xlink:href="#MJMATHI-3B7">< use x="2819" y="0" xlink:href="#MJMAIN-29">< g transform="translate(16581,0)">< use x="0" y="0" xlink:href="#MJMATHI-68">< use transform="scale(0.707)" x="815" y="583" xlink:href="#MJMAIN-2032">< use x="17452" y="0" xlink:href="#MJMAIN-28">< use x="17842" y="0" xlink:href="#MJMATHI-74">< use x="18203" y="0" xlink:href="#MJMAIN-7C">< use x="18482" y="0" xlink:href="#MJMATHI-62">< use x="18911" y="0" xlink:href="#MJMAIN-2C">< use x="19356" y="0" xlink:href="#MJMATHI-3B7">< use x="19860" y="0" xlink:href="#MJMAIN-29">
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="59.793ex" height="6.009ex" style="vertical-align: -2.671ex;" viewBox="0 -1437.2 25744.2 2587.3" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(778,0)">< g transform="translate(397,0)">< rect stroke="none" width="450" x="0" y="220">< use x="1414" y="676" xlink:href="#MJMAIN-31">< g transform="translate(60,-771)">< use x="0" y="0" xlink:href="#MJMATHI-4D">< use x="1051" y="0" xlink:href="#MJMAIN-28">< use x="1441" y="0" xlink:href="#MJMATHI-62">< use x="1870" y="0" xlink:href="#MJMAIN-2C">< use x="2315" y="0" xlink:href="#MJMATHI-3B7">< use x="2819" y="0" xlink:href="#MJMAIN-29">< g transform="translate(4624,0)">< use x="0" y="-1" xlink:href="#MJSZ1-7B">< g transform="translate(583,0)">< use x="0" y="0" xlink:href="#MJMAIN-31">< g transform="translate(500,-187)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-5B">< use transform="scale(0.707)" x="278" y="0" xlink:href="#MJMAIN-30">< use transform="scale(0.707)" x="779" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(747,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="386" xlink:href="#MJMAIN-2217">< use transform="scale(0.707)" x="1925" y="0" xlink:href="#MJMAIN-5D">< use x="2381" y="0" xlink:href="#MJMAIN-2217">< use x="3103" y="0" xlink:href="#MJMATHI-6D">< use x="3982" y="0" xlink:href="#MJMAIN-28">< use x="4371" y="0" xlink:href="#MJMATHI-62">< use x="4801" y="0" xlink:href="#MJMAIN-2C">< use x="5246" y="0" xlink:href="#MJMATHI-3B7">< use x="5749" y="0" xlink:href="#MJMAIN-29">< use x="6361" y="0" xlink:href="#MJMAIN-2B">< g transform="translate(7362,0)">< use x="0" y="0" xlink:href="#MJMAIN-31">< g transform="translate(500,-187)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-28">< g transform="translate(275,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="386" xlink:href="#MJMAIN-2217">< use transform="scale(0.707)" x="1257" y="0" xlink:href="#MJMAIN-2C">< use transform="scale(0.707)" x="1535" y="0" xlink:href="#MJMAIN-2B">< use transform="scale(0.707)" x="2314" y="0" xlink:href="#MJMAIN-221E">< use transform="scale(0.707)" x="3314" y="0" xlink:href="#MJMAIN-29">< use x="10804" y="0" xlink:href="#MJMAIN-2217">< use x="11527" y="0" xlink:href="#MJMAIN-28">< use x="11916" y="0" xlink:href="#MJMAIN-31">< use x="12639" y="0" xlink:href="#MJMAIN-2B">< use x="13640" y="0" xlink:href="#MJMATHI-3B7">< use x="14143" y="0" xlink:href="#MJMAIN-29">< use x="14755" y="0" xlink:href="#MJMAIN-2217">< use x="15478" y="0" xlink:href="#MJMATHI-62">< g transform="translate(16074,0)">< use xlink:href="#MJMAIN-65">< use x="444" y="0" xlink:href="#MJMAIN-78">< use x="973" y="0" xlink:href="#MJMAIN-70">< use x="17603" y="0" xlink:href="#MJMAIN-28">< use x="17993" y="0" xlink:href="#MJMAIN-2212">< use x="18771" y="0" xlink:href="#MJMATHI-62">< use x="19201" y="0" xlink:href="#MJMATHI-74">< use x="19562" y="0" xlink:href="#MJMAIN-29">< use x="20535" y="-1" xlink:href="#MJSZ1-7D">
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="71.215ex" height="6.843ex" style="vertical-align: -2.671ex;" viewBox="0 -1796 30661.8 2946.1" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(778,0)">< g transform="translate(397,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,770)">< use x="0" y="0" xlink:href="#MJMATHI-6D">< use x="878" y="0" xlink:href="#MJMAIN-28">< use x="1268" y="0" xlink:href="#MJMATHI-62">< use x="1697" y="0" xlink:href="#MJMAIN-2C">< use x="2142" y="0" xlink:href="#MJMATHI-3B7">< use x="2646" y="0" xlink:href="#MJMAIN-29">< g transform="translate(3035,0)">< use x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="511" y="513" xlink:href="#MJMAIN-2217">< g transform="translate(381,-771)">< use x="0" y="0" xlink:href="#MJMATHI-4D">< use x="1051" y="0" xlink:href="#MJMAIN-28">< use x="1441" y="0" xlink:href="#MJMATHI-62">< use x="1870" y="0" xlink:href="#MJMAIN-2C">< use x="2315" y="0" xlink:href="#MJMATHI-3B7">< use x="2819" y="0" xlink:href="#MJMAIN-29">< use x="5489" y="0" xlink:href="#MJMAIN-2217">< g transform="translate(5990,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< use x="217" y="676" xlink:href="#MJMAIN-31">< g transform="translate(60,-686)">< use x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="511" y="408" xlink:href="#MJMAIN-2217">< g transform="translate(7387,0)">< use x="0" y="0" xlink:href="#MJMAIN-31">< g transform="translate(500,-187)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-5B">< use transform="scale(0.707)" x="278" y="0" xlink:href="#MJMAIN-30">< use transform="scale(0.707)" x="779" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(747,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="386" xlink:href="#MJMAIN-2217">< use transform="scale(0.707)" x="1925" y="0" xlink:href="#MJMAIN-5D">< use x="9768" y="0" xlink:href="#MJMAIN-2B">< g transform="translate(10547,0)">< g transform="translate(342,0)">< rect stroke="none" width="450" x="0" y="220">< g transform="translate(60,770)">< use x="0" y="0" xlink:href="#MJMATHI-6D">< use x="878" y="0" xlink:href="#MJMAIN-28">< use x="1268" y="0" xlink:href="#MJMATHI-62">< use x="1697" y="0" xlink:href="#MJMAIN-2C">< use x="2142" y="0" xlink:href="#MJMATHI-3B7">< use x="2646" y="0" xlink:href="#MJMAIN-29">< g transform="translate(3035,0)">< use x="0" y="0" xlink:href="#MJMATHI-65">< g transform="translate(466,362)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-2212">< use transform="scale(0.707)" x="778" y="0" xlink:href="#MJMATHI-62">< g transform="translate(854,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="446" xlink:href="#MJMAIN-2217">< use x="5070" y="0" xlink:href="#MJMAIN-28">< use x="5459" y="0" xlink:href="#MJMAIN-31">< use x="6182" y="0" xlink:href="#MJMAIN-2B">< use x="7182" y="0" xlink:href="#MJMATHI-3B7">< use x="7686" y="0" xlink:href="#MJMAIN-29">< g transform="translate(2493,-771)">< use x="0" y="0" xlink:href="#MJMATHI-4D">< use x="1051" y="0" xlink:href="#MJMAIN-28">< use x="1441" y="0" xlink:href="#MJMATHI-62">< use x="1870" y="0" xlink:href="#MJMAIN-2C">< use x="2315" y="0" xlink:href="#MJMATHI-3B7">< use x="2819" y="0" xlink:href="#MJMAIN-29">< use x="19427" y="0" xlink:href="#MJMAIN-2217">< g transform="translate(20150,0)">< use x="0" y="0" xlink:href="#MJMAIN-31">< g transform="translate(500,-187)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMAIN-28">< g transform="translate(275,0)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="386" xlink:href="#MJMAIN-2217">< use transform="scale(0.707)" x="1257" y="0" xlink:href="#MJMAIN-2C">< use transform="scale(0.707)" x="1535" y="0" xlink:href="#MJMAIN-2B">< use transform="scale(0.707)" x="2314" y="0" xlink:href="#MJMAIN-221E">< use transform="scale(0.707)" x="3314" y="0" xlink:href="#MJMAIN-29">< use x="23370" y="0" xlink:href="#MJMATHI-62">< g transform="translate(23966,0)">< use xlink:href="#MJMAIN-65">< use x="444" y="0" xlink:href="#MJMAIN-78">< use x="973" y="0" xlink:href="#MJMAIN-70">< use x="25495" y="0" xlink:href="#MJMAIN-28">< use x="25885" y="0" xlink:href="#MJMAIN-2212">< use x="26663" y="0" xlink:href="#MJMATHI-62">< use x="27093" y="0" xlink:href="#MJMAIN-28">< use x="27482" y="0" xlink:href="#MJMATHI-74">< use x="28066" y="0" xlink:href="#MJMAIN-2212">< g transform="translate(29067,0)">< use x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="511" y="583" xlink:href="#MJMAIN-2217">< use x="29882" y="0" xlink:href="#MJMAIN-29">< use x="30272" y="0" xlink:href="#MJMAIN-29">
< svg xmlns:xlink="http://www.w3.org/1999/xlink" width="40.645ex" height="3.176ex" style="vertical-align: -1.005ex;" viewBox="0 -934.9 17499.8 1367.4" role="img" focusable="false">< g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">< use x="0" y="0" xlink:href="#MJMAIN-3D">< g transform="translate(1056,0)">< use x="0" y="0" xlink:href="#MJMATHI-70">< use transform="scale(0.707)" x="712" y="-213" xlink:href="#MJMAIN-31">< use x="2013" y="0" xlink:href="#MJMAIN-28">< use x="2403" y="0" xlink:href="#MJMATHI-62">< use x="2832" y="0" xlink:href="#MJMAIN-2C">< use x="3277" y="0" xlink:href="#MJMATHI-3B7">< use x="3781" y="0" xlink:href="#MJMAIN-29">< use x="4393" y="0" xlink:href="#MJMAIN-2217">< use x="5115" y="0" xlink:href="#MJAMS-55">< use x="5838" y="0" xlink:href="#MJMAIN-5B">< use x="6116" y="0" xlink:href="#MJMAIN-30">< use x="6617" y="0" xlink:href="#MJMAIN-2C">< g transform="translate(7062,0)">< use x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.707)" x="511" y="583" xlink:href="#MJMAIN-2217">< use x="7877" y="0" xlink:href="#MJMAIN-5D">< use x="8378" y="0" xlink:href="#MJMAIN-2B">< g transform="translate(9379,0)">< use x="0" y="0" xlink:href="#MJMATHI-70">< use transform="scale(0.707)" x="712" y="-213" xlink:href="#MJMAIN-32">< use x="10336" y="0" xlink:href="#MJMAIN-28">< use x="10726" y="0" xlink:href="#MJMATHI-62">< use x="11155" y="0" xlink:href="#MJMAIN-2C">< use x="11600" y="0" xlink:href="#MJMATHI-3B7">< use x="12104" y="0" xlink:href="#MJMAIN-29">< use x="12716" y="0" xlink:href="#MJMAIN-2217">< g transform="translate(13438,0)">< use x="0" y="0" xlink:href="#MJMAIN-45">< use x="681" y="0" xlink:href="#MJMAIN-78">< use x="1210" y="0" xlink:href="#MJMAIN-70">< use x="15205" y="0" xlink:href="#MJMAIN-28">< use x="15594" y="0" xlink:href="#MJMATHI-62">< use x="16024" y="0" xlink:href="#MJMAIN-29">< g transform="translate(16413,0)">< use x="0" y="0" xlink:href="#MJMAIN-7C">< use transform="scale(0.707)" x="393" y="675" xlink:href="#MJMAIN-221E">< g transform="translate(278,-286)">< use transform="scale(0.707)" x="0" y="0" xlink:href="#MJMATHI-74">< use transform="scale(0.574)" x="445" y="386" xlink:href="#MJMAIN-2217">

which is mixture of uniform and truncated exponential distribution.

Algorithm pseudocode

select component with probabilities p1(b, eta) and p2(b, eta)
Repeat
  sample y from selected density component
  sample u from U[0, h'(y|b, eta)]
Until u < p(y|b, eta)

Sampling results

Kolmogorov Smirnov test

It’s straightforward to test whether we sample from correct distributions by comparing empirical cumulative distribution function with exact one.

	One-sample Kolmogorov-Smirnov test

data:  s
D = 0.0018236, p-value = 0.8936
alternative hypothesis: two-sided

Perfect! Sampled data distribution is indistinguishable from theoretical density. We can also inspect sampling results visually:

Summary

We created from scratch new sampler for shifted Gompertz distribution 🙂 and it’s fairly efficient: for one milion of sampled values it takes latter algorithm only 0.138 of a second.

Code for this post can be found here: https://github.com/jakubglinka/posts/tree/master/diffusion_part1

  1. Bauckhage, Christian; Kersting, Kristian (2014). “Strong Regularities in Growth and Decline of Popularity of Social Media Services”

To leave a comment for the author, please follow the link and comment on their blog: Jakub Glinka's Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.