Skip to content

Instantly share code, notes, and snippets.

@gfredericks
Last active April 26, 2017 14:28
Show Gist options
  • Save gfredericks/b6b59f1c531dc36017e45f2f0beeff9e to your computer and use it in GitHub Desktop.
Save gfredericks/b6b59f1c531dc36017e45f2f0beeff9e to your computer and use it in GitHub Desktop.
Proposed distribution for a bigint generator in test.check.
;; goals:
;; - unbounded distribution (arbitrarily large bigints can be generated,
;; even for small `size`)
;; - but respects `size` -- with larger `size`, larger numbers are likely
;; to be generated
;; - has a roughly 0.1% chance of generating an integer larger than
;; Double/MAX_VALUE (2^1024)
;; sizing background: https://github.com/clojure/test.check/blob/master/doc/growth-and-shrinking.md
(sample gen/bigint 200)
;; note that the `size` for the numbers listed here increases from 0 to 199
;; =>
[
⇰ 0
⇰ -1
⇰ 0
⇰ 0
⇰ -2
⇰ 0
⇰ -122
⇰ -108952
⇰ 0
⇰ 6
⇰ -5502438
⇰ -3
⇰ -2
⇰ 14
⇰ -2060091
⇰ -9118681
⇰ -32917317366393212103814
⇰ -21535
⇰ 6
⇰ -7183015976645151
⇰ 9
⇰ -58936185
⇰ -17726067119
⇰ 76
⇰ 4092073960623
⇰ -120776159108
⇰ -50769158387
⇰ -1845
⇰ -1117084924
⇰ 591
⇰ -1040856618530
⇰ 2631005007570719766591997772022681493005143178984598
⇰ 95206
⇰ 7
⇰ -686176
⇰ -6
⇰ 33399567699598843984899
⇰ -235062803520645
⇰ -366
⇰ -288265637526816552401
⇰ -14985883701066223017474927
⇰ 4397572116125352
⇰ 6676
⇰ 1490556
⇰ 509982039086837619010
⇰ -43003
⇰ 2
⇰ 137156
⇰ -1780156
⇰ 123763292079
⇰ 755298849013321631001
⇰ -1
⇰ 0
⇰ -3561875178412680284851
⇰ 928802156721257
⇰ -2419440371937608046950
⇰ -5744095448016139848839022266653662670675404037032684
⇰ -1
⇰ 28892564098
⇰ -651409
⇰ 37474046578743766728197175
⇰ 464204587
⇰ 3497144
⇰ 4
⇰ -760497478582296969463171692826687790
⇰ -1
⇰ 24644501808
⇰ 21275
⇰ -8922
⇰ 9
⇰ -4248691420160285523160
⇰ 230614542
⇰ -33225705275468
⇰ -21
⇰ -1281344086172683
⇰ -766978708033
⇰ 15963808829322
⇰ -69427076635392397325771055074807269078098184982441112609440495461643005
79232250557565980613362845719245740168062029969590845621029496914696143
⇰ -221097547988830334228339084720180024384294635294361622274334591896539
⇰ 0
⇰ -94567124945711028939805463552129976380206007342389
⇰ -619
⇰ -7508
⇰ -3206898776564
⇰ 26012786272049605677780843797150326846144867
⇰ -19673776965
⇰ -487996945027934940
⇰ -3930217219136692438315309
⇰ 8933663
⇰ 423639245069127861336076814685063832979530797707840720674642464120104358
55611485538652199809774106
⇰ -23708731
⇰ 1084495221070382779938772465007482621598263
⇰ 285532442947440470476143818986
⇰ 794212084474784676931058235947126617723926026420961761905888208504053389
515625
⇰ -18
⇰ 12676387044
⇰ 84
⇰ 84
⇰ 1493278
⇰ 58
⇰ 10795645623418208488147895516132960897920570541072848
⇰ 11952561035990456140645444167153878678185509577220
⇰ -204457338059902010522795
⇰ 744331187853881238630957384500748092931639842139256923257240
⇰ -936128047889047186479234
⇰ -7654561982
⇰ 5923762713757
⇰ -121997128286633
⇰ 542226170694507919726291391043304
⇰ 67300158941185627339841002868691331658826
⇰ 6118318283620492247787585681683
⇰ 439578753744214218210601482611191973875664355309519838024172765900183400
89102904819
⇰ -6909519252
⇰ -18613455428275706622931
⇰ 2904247944366901315301314508382224
⇰ 1113587031702725665588395503
⇰ 32968328314692929243019583342500863667065481
⇰ -1069744580209654150224780846203187865865540838486
⇰ 642151637758355246327423489658742261001323500839877195566830485360467703
028087332741464087774636099319963175972965315740967333212085825698900868
43234974439410494738438376262836677920
⇰ -2792513948
⇰ -162220955141
⇰ -1499917605481018807
⇰ -909627898926866718112098
⇰ -2820571508048705281356029009269743956456141834956577659285388
⇰ -10660
⇰ 4976735301250070063271985760472373881
⇰ 5666530682793359256093389039628435320417485012445
⇰ 84705262411436766580174245590058972239
⇰ -854588500035265324708697518121778
⇰ 644396205764553903468466643910428
⇰ -32061602008592940478
⇰ -1
⇰ 11770242263668646508608172523725
⇰ 197306301479242089798999727884954991202962027286933986880139324
⇰ -3916456751247515
⇰ 79770857121579477980729482118026497362692
⇰ -49059382420854218788604892722367890524205791713
⇰ 87437158271780537907388248310276730775408670534044355659691
⇰ -44607809671937580566
⇰ 37982485236739229598917044
⇰ 5198501
⇰ 303881251398303065048889457824896948130250204130451182945583067654830328
49666837971070360882675
⇰ -51833918686542285886279978310960433581317110797203782235944242875219030
655769168549997725117615822516754073602137401988624622812918782717476646404
⇰ 585762305006263572421479758870864002861534950589035693946384678316570670
000510733470481121948915965035365723148852254500
⇰ -2283
⇰ -195211265894306578006858044344205132201760
⇰ -18498365769826240319892496752710189132516176018347113964787302571796019
04317581950580864805024279942566943204
⇰ -6301398436375233537434498294550
⇰ 229134398075
⇰ 17199845334041899633657961585186318826
⇰ -242118323808308293
⇰ -6855013
⇰ 289670196
⇰ -18691384356942455579086674380536565441357448920633168
⇰ -6330153235197
⇰ 0
⇰ -92948230
⇰ -71705673542696743834514610075266899412032426779785168
⇰ -14
⇰ 8
⇰ 16189792351185535803287486026704181614832843920413927520
⇰ 1264776652342341279120587336086959
⇰ -9000044376174125374409451864008958428225892068503613256
⇰ 43376626878075877385
⇰ -4107499540
⇰ -424209600944377206385988240676116669435896859202881426293250737853593444
⇰ -154041703814001550144857201033
⇰ 14814238944043493687919470325946351515286597
⇰ 2391497581563089032615292284683275609046908918065153124910077509
⇰ -41480331698848462647
⇰ -54262586387834713622452814478807267631104708033880106525992
⇰ 22126988095356
⇰ 68059547776720
⇰ 97182498010667613257669548055796354110
⇰ -42451909604469023540179282940818759838225944115984517417418762935614233
544290320879259112214294325146811346345418484863970325961367547887067073
6352232606051375
⇰ -28928580283
⇰ 119475591865248877729416
⇰ -38766551080916901869276203244270794520920430265246472554804447600962634
8774221
⇰ 467458321687160914752101227
⇰ 8742
⇰ 893992202
⇰ -10675395282600823621122569154556851603174377728323780537237472406529547
30207191548480
⇰ 29924713701143653016
⇰ -171974509198104
⇰ 521413405520644506471621256900675264000921820286252753253243293043618468
86563340290954201937227
⇰ -1122719472874273683330656497192378192391463227323157
⇰ 456370370941917135664756024958964860235433423595523370124258004631955000
90077473231951679908747197194842818
⇰ -405236715540762563038714631127292
⇰ -43905233134238811425237094535334508585424098677990
⇰ 8
⇰ 14678765808026287909481093810393897204530
⇰ 469891713114897966594000734216430581763398854150536337690031757187673633
089765194870872124998490796780354824365246974096944010270889138456085972
858028101655104596202431945110612957603113574155772038931231769911979506
030654441992225865682026943289046312194476370122157589887512710832189749
42101880822112128593661983070496517251545108229043374881053118692371227986
⇰ -101081733635685453657872353238151115008582393810234779796306422
⇰ 123902427722835799206943901514505088588305723220682502133102386092566687
2742296541492025929304832
⇰ -151853146740910022041358304697844375581404563464
⇰ 74860984228275857894916
⇰ 210316771876211210073401300
⇰ 2533757192193785124231697275124
⇰ -420292904979567457169704067381128531876657877956573
⇰ -20990751250596705560338583331350236112030225800900260125743730619205225
628585969432987809463963686765261347308173021058216067434573720318930529
529087291971292609522939951160471485436538462474517968217982391085077130
967479618192965696531
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment