ScaDaMaLe Course site and book

Core ideas in Monte Carlo simulation

  • modular arithmetic gives pseudo-random streams that are indistiguishable from 'true' Uniformly distributed samples in integers from \({0,1,2,...,m}\)
  • by diving the integer streams from above by \(m\) we get samples from \({0/m,1/m,...,(m-1)/m}\) and "pretend" this to be samples from the Uniform(0,1) RV
  • we can use inverse distribution function of von Neumann's rejection sampler to convert samples from Uniform(0,1) RV to the following:
    • any other random variable
    • vector of random variables that could be dependent
    • or more generally other random structures:
      • random graphs and networks
      • random walks or (sensible perturbations of live traffic data on open street maps for hypothesis tests)
      • models of interacting paticle systems in ecology / chemcal physics, etc...

breeze.stats.distributions

Breeze also provides a fairly large number of probability distributions. These come with access to probability density function for either discrete or continuous distributions. Many distributions also have methods for giving the mean and the variance.

Let us simulate from the Poisson distribution with the following probability mass and cumulative distribution functions:

Poisson PMF Poisson CDF

import breeze.stats.distributions._

val poi = new Poisson(3.0);
import breeze.stats.distributions._
poi: breeze.stats.distributions.Poisson = Poisson(3.0)
val s = poi.sample(5); // let's draw five samples - black-box
s: IndexedSeq[Int] = Vector(3, 2, 5, 4, 1)

Getting probabilities of the Poisson samples

s.map( x => poi.probabilityOf(x) ) // PMF
res0: IndexedSeq[Double] = Vector(0.22404180765538775, 0.22404180765538775, 0.10081881344492458, 0.16803135574154085, 0.14936120510359185)
val doublePoi = for(x <- poi) yield x.toDouble // meanAndVariance requires doubles, but Poisson samples over Ints
doublePoi: breeze.stats.distributions.Rand[Double] = MappedRand(Poisson(3.0),$Lambda$8556/443731598@3fbbf491)
breeze.stats.meanAndVariance(doublePoi.samples.take(1000));
res1: breeze.stats.meanAndVariance.MeanAndVariance = MeanAndVariance(3.0660000000000034,3.250894894894892,1000)
(poi.mean, poi.variance) // population mean and variance
res1: (Double, Double) = (3.0,3.0)

Exponential random Variable

Let's focus on getting our hands dirty with the Exponential random variable, a common continuous RV with rate parameter \(\lambda\) with the following probability density and distribution functions:

NOTE: Below, there is a possibility of confusion for the term rate in the family of exponential distributions. Breeze parameterizes the distribution with the mean, but refers to it as the rate.

val expo = new Exponential(0.5);
expo: breeze.stats.distributions.Exponential = Exponential(0.5)
expo.rate // what is the rate parameter
res2: Double = 0.5

A characteristic of exponential distributions is its half-life, but we can compute the probability a value falls between any two numbers.

expo.probability(0, math.log(2) * expo.rate)
res3: Double = 0.1591035847462855
expo.probability(math.log(2) * expo.rate, 10000.0)
res4: Double = 0.8408964152537145
expo.probability(0.0, 1.5)
res5: Double = 0.5276334472589853

The above result means that approximately 95% of the draws from an exponential distribution fall between 0 and thrice the mean. We could have easily computed this with the cumulative distribution as well.

1 - math.exp(-3.0) // the CDF of the Exponential RV with rate parameter 3
res6: Double = 0.950212931632136

Drawing samples from Exponential RV

Using the Inverse Transform Sampling, we can sample from the Exponential RV by transforming the samples from the standard Uniform RV as shown in the animation below:

val samples = expo.sample(2).sorted; // built-in black box - we will roll our own shortly in Spark
samples: IndexedSeq[Double] = Vector(0.5783204633797516, 2.470656843546517)
expo.probability(samples(0), samples(1));
res7: Double = 0.4581529379432925
breeze.stats.meanAndVariance(expo.samples.take(10000)); // mean and variance of the sample
res8: breeze.stats.meanAndVariance.MeanAndVariance = MeanAndVariance(1.9763018410146713,3.9243880003317417,10000)
(1 / expo.rate, 1 / (expo.rate * expo.rate)) // mean and variance of the population
res9: (Double, Double) = (2.0,4.0)
import spark.implicits._
import org.apache.spark.sql.functions._
import spark.implicits._
import org.apache.spark.sql.functions._
val df = spark.range(1000).toDF("Id") // just make a DF of 1000 row indices
df: org.apache.spark.sql.DataFrame = [Id: bigint]
df.show(5)
+---+
| Id|
+---+
|  0|
|  1|
|  2|
|  3|
|  4|
+---+
only showing top 5 rows
val dfRand = df.select($"Id", rand(seed=1234567) as "rand") // add a column of random numbers in (0,1)
dfRand: org.apache.spark.sql.DataFrame = [Id: bigint, rand: double]
dfRand.show(5) // these are first 5 of the 1000 samples from the Uniform(0,1) RV
+---+--------------------+
| Id|                rand|
+---+--------------------+
|  0|0.024042816995877625|
|  1|  0.4763832311243641|
|  2|  0.3392911406256911|
|  3|  0.6282132043405342|
|  4|  0.9665960987271114|
+---+--------------------+
only showing top 5 rows
val dfRand = df.select($"Id", rand(seed=1234567) as "rand") // add a column of random numbers in (0,1)
dfRand.show(5) // these are first 5 of the 1000 samples from the Uniform(0,1) RV
+---+--------------------+
| Id|                rand|
+---+--------------------+
|  0|0.024042816995877625|
|  1|  0.4763832311243641|
|  2|  0.3392911406256911|
|  3|  0.6282132043405342|
|  4|  0.9665960987271114|
+---+--------------------+
only showing top 5 rows

dfRand: org.apache.spark.sql.DataFrame = [Id: bigint, rand: double]
val dfRand = df.select($"Id", rand(seed=879664) as "rand") // add a column of random numbers in (0,1)
dfRand.show(5) // these are first 5 of the 1000 samples from the Uniform(0,1) RV
+---+-------------------+
| Id|               rand|
+---+-------------------+
|  0|  0.269224348263137|
|  1|0.20433965628039852|
|  2| 0.8481228617934538|
|  3| 0.6665103087537884|
|  4| 0.7712898780552342|
+---+-------------------+
only showing top 5 rows

dfRand: org.apache.spark.sql.DataFrame = [Id: bigint, rand: double]

Let's use the inverse CDF of the Exponential RV to transform these samples from the Uniform(0,1) RV into those from the Exponential RV.

val dfRand = df.select($"Id", rand(seed=1234567) as "rand") // add a column of random numbers in (0,1)
               .withColumn("one",lit(1.0))
               .withColumn("rate",lit(0.5))
dfRand: org.apache.spark.sql.DataFrame = [Id: bigint, rand: double ... 2 more fields]
dfRand.show(5) 
+---+--------------------+---+----+
| Id|                rand|one|rate|
+---+--------------------+---+----+
|  0|0.024042816995877625|1.0| 0.5|
|  1|  0.4763832311243641|1.0| 0.5|
|  2|  0.3392911406256911|1.0| 0.5|
|  3|  0.6282132043405342|1.0| 0.5|
|  4|  0.9665960987271114|1.0| 0.5|
+---+--------------------+---+----+
only showing top 5 rows
val dfExpRand = dfRand.withColumn("expo_sample", -($"one" / $"rate") * log($"one" - $"rand")) // samples from expo(rate=0.5)
dfExpRand: org.apache.spark.sql.DataFrame = [Id: bigint, rand: double ... 3 more fields]
dfExpRand.show(5)
+---+--------------------+---+----+--------------------+
| Id|                rand|one|rate|         expo_sample|
+---+--------------------+---+----+--------------------+
|  0|0.024042816995877625|1.0| 0.5|0.048673126808362034|
|  1|  0.4763832311243641|1.0| 0.5|  1.2939904386814756|
|  2|  0.3392911406256911|1.0| 0.5|  0.8288839819270684|
|  3|  0.6282132043405342|1.0| 0.5|  1.9788694379168241|
|  4|  0.9665960987271114|1.0| 0.5|   6.798165162486205|
+---+--------------------+---+----+--------------------+
only showing top 5 rows
display(dfExpRand)
Id rand one rate expo_sample
0.0 2.4042816995877625e-2 1.0 0.5 4.8673126808362034e-2
1.0 0.4763832311243641 1.0 0.5 1.2939904386814756
2.0 0.3392911406256911 1.0 0.5 0.8288839819270684
3.0 0.6282132043405342 1.0 0.5 1.9788694379168241
4.0 0.9665960987271114 1.0 0.5 6.798165162486205
5.0 0.8269758822163711 1.0 0.5 3.508648570093974
6.0 0.3404052214826948 1.0 0.5 0.8322592089262
7.0 0.5658253891225227 1.0 0.5 1.6686169931673005
8.0 0.11737981749647353 1.0 0.5 0.24972063061386013
9.0 0.7848668745585088 1.0 0.5 3.072996508744745
10.0 0.10665116151243736 1.0 0.5 0.2255562755600773
11.0 0.34971775733163646 1.0 0.5 0.8606975816973311
12.0 3.349566781262969e-2 1.0 0.5 6.813899599567436e-2
13.0 0.334063669089834 1.0 0.5 0.8131224244912618
14.0 0.4105052702588069 1.0 0.5 1.0569789985263547
15.0 0.22519777483698333 1.0 0.5 0.5102949510683874
16.0 0.21124107883891907 1.0 0.5 0.47458910937069004
17.0 0.12332274767843698 1.0 0.5 0.26323273531964136
18.0 4.324422155449681e-2 1.0 0.5 8.841423006745963e-2
19.0 3.933267172708754e-2 1.0 0.5 8.025420479220831e-2
20.0 0.8162723223794007 1.0 0.5 3.388601261211285
21.0 7.785566240785313e-2 1.0 0.5 0.16210703862675058
22.0 0.1244015150504949 1.0 0.5 0.26569528726942954
23.0 0.5313795676534989 1.0 0.5 1.5159243018004147
24.0 0.8177063965639969 1.0 0.5 3.4042733720631824
25.0 0.7757379079578416 1.0 0.5 2.98987971469377
26.0 0.9019086568714294 1.0 0.5 4.643712323362237
27.0 0.5793202308042869 1.0 0.5 1.7317667559523853
28.0 4.913530139386124e-2 1.0 0.5 0.10076699863506142
29.0 0.6984668419742928 1.0 0.5 2.3977505839877837
30.0 1.579141234703818e-2 1.0 0.5 3.18348501444197e-2
31.0 0.3170147319677016 1.0 0.5 0.762563978285606
32.0 0.6243818511105477 1.0 0.5 1.9583644261768265
33.0 0.9720896733059052 1.0 0.5 7.157517052464175
34.0 6.406755887221727e-2 1.0 0.5 0.13242396678361196
35.0 0.8275324400058236 1.0 0.5 3.515092236401242
36.0 0.4223760255739688 1.0 0.5 1.0976643705892708
37.0 0.6237792697270514 1.0 0.5 1.9551585184791915
38.0 0.30676209726152626 1.0 0.5 0.7327640894184466
39.0 0.7209798363387625 1.0 0.5 2.5529424571699533
40.0 0.5408086036735253 1.0 0.5 1.556576340750279
41.0 0.22254408000797787 1.0 0.5 0.5034566621599345
42.0 0.6478051949133747 1.0 0.5 2.0871416658496442
43.0 0.6186563924196967 1.0 0.5 1.9281089062362353
44.0 0.2689179760895458 1.0 0.5 0.6264592354306907
45.0 0.1310898372764776 1.0 0.5 0.28103107825164747
46.0 0.8459785027719904 1.0 0.5 3.741326187841892
47.0 0.7844461581951896 1.0 0.5 3.069089109365284
48.0 0.3195541476806115 1.0 0.5 0.7700140609818293
49.0 0.326892158146161 1.0 0.5 0.7916994433570004
50.0 0.4392312327086285 1.0 0.5 1.1568932758900772
51.0 0.5377790694946909 1.0 0.5 1.543424595293625
52.0 0.4369640582174875 1.0 0.5 1.1488236262486446
53.0 0.26672242876690055 1.0 0.5 0.6204619408451196
54.0 0.9743181848790359 1.0 0.5 7.323944240755433
55.0 0.5636877255447679 1.0 0.5 1.6587941323713102
56.0 0.8214194684040824 1.0 0.5 3.44543124420649
57.0 4.2394218638494574e-2 1.0 0.5 8.663817482333575e-2
58.0 0.2986030735782996 1.0 0.5 0.7093626466953578
59.0 0.9251464009715654 1.0 0.5 5.184442172120483
60.0 0.9768531076059933 1.0 0.5 7.531789490600966
61.0 0.4147651110232632 1.0 0.5 1.0714839854387161
62.0 0.4525161010109643 1.0 0.5 1.2048444519262322
63.0 7.638776464132979e-2 1.0 0.5 0.1589259082490955
64.0 0.8203900440907219 1.0 0.5 3.433935381714252
65.0 0.9746746584977457 1.0 0.5 7.35189948830076
66.0 0.41832172801299305 1.0 0.5 1.083675562745256
67.0 3.3131200470495226e-2 1.0 0.5 6.738494114620364e-2
68.0 0.10008247055930286 1.0 0.5 0.21090430762250917
69.0 0.4268021831375646 1.0 0.5 1.113048783438383
70.0 0.8213380254753332 1.0 0.5 3.444519337826204
71.0 0.47431121070064797 1.0 0.5 1.2860917933318652
72.0 0.68679164992865 1.0 0.5 2.321773309424188
73.0 0.7057803676609208 1.0 0.5 2.4468574835462356
74.0 0.32184620342731496 1.0 0.5 0.776762356325894
75.0 0.3589329148022541 1.0 0.5 0.8892423408857425
76.0 0.7448782338623747 1.0 0.5 2.7320286670643386
77.0 0.9740613004640858 1.0 0.5 7.304038469785621
78.0 0.7453909609063684 1.0 0.5 2.736052180743762
79.0 6.853610233988816e-2 1.0 0.5 0.14199569380051374
80.0 0.336012781812836 1.0 0.5 0.8189847588182159
81.0 0.2963058480260412 1.0 0.5 0.7028229208813994
82.0 0.38627232525200883 1.0 0.5 0.9764079513820425
83.0 0.9097248909817963 1.0 0.5 4.809787008391862
84.0 0.20679745942261907 1.0 0.5 0.46335335878970363
85.0 0.16582497569469312 1.0 0.5 0.36262407472768277
86.0 0.6960738838737711 1.0 0.5 2.381941292346302
87.0 0.890094879396298 1.0 0.5 4.416275650715409
88.0 0.8258738496535992 1.0 0.5 3.4959504809275685
89.0 0.4066244237870885 1.0 0.5 1.0438554620679272
90.0 0.44414816275414526 1.0 0.5 1.1745070000344822
91.0 0.8820223175378497 1.0 0.5 4.274519608161631
92.0 0.3814200182827251 1.0 0.5 0.9606575597598919
93.0 0.491252177347836 1.0 0.5 1.3516056440673538
94.0 0.9042145561359308 1.0 0.5 4.691289097027222
95.0 0.8293982814391448 1.0 0.5 3.536847140695551
96.0 0.6957817964411346 1.0 0.5 2.38002012037681
97.0 0.46108317902841456 1.0 0.5 1.2363880819986401
98.0 0.658234439306857 1.0 0.5 2.14726054405596
99.0 0.43175037735005384 1.0 0.5 1.130388960612226
100.0 0.7719881477151886 1.0 0.5 2.9567153353469786
101.0 6.397418621476536e-2 1.0 0.5 0.13222444810891013
102.0 0.44410081132020296 1.0 0.5 1.1743366329905425
103.0 0.9364231799229901 1.0 0.5 5.511012678534471
104.0 0.5453471566845608 1.0 0.5 1.576442265948382
105.0 0.7346238968987211 1.0 0.5 2.653214404406468
106.0 0.3493365535175731 1.0 0.5 0.8595254994862054
107.0 0.5230037795263933 1.0 0.5 1.480493423321206
108.0 0.6886814284788837 1.0 0.5 2.333877090719847
109.0 0.7731252946239237 1.0 0.5 2.966714745163421
110.0 2.276168830750991e-2 1.0 0.5 4.604946957472576e-2
111.0 0.264951110753621 1.0 0.5 0.6156365319998442
112.0 0.14616140102686104 1.0 0.5 0.3160261944637388
113.0 3.066619523108849e-2 1.0 0.5 6.229248529326732e-2
114.0 0.49017052188807597 1.0 0.5 1.3473579316333943
115.0 9.835381148010536e-2 1.0 0.5 0.20706617613153588
116.0 8.828156810764243e-2 1.0 0.5 0.1848481470740138
117.0 0.6868446103815881 1.0 0.5 2.3221115183574854
118.0 0.4067862578001439 1.0 0.5 1.0444010055396156
119.0 0.44070042328022496 1.0 0.5 1.1621400679168603
120.0 0.19523663294276805 1.0 0.5 0.4344139974853618
121.0 0.34930320794183467 1.0 0.5 0.8594230049585315
122.0 0.37713232784782635 1.0 0.5 0.9468423740115679
123.0 0.6429635193876022 1.0 0.5 2.0598346316676848
124.0 0.5726782020473655 1.0 0.5 1.7004358488091253
125.0 0.3013872989669776 1.0 0.5 0.7173175321607891
126.0 0.3469657736553403 1.0 0.5 0.8522514741503977
127.0 0.3062597218624077 1.0 0.5 0.7313152550300903
128.0 0.875187814442521 1.0 0.5 4.161890374256847
129.0 0.4331447487608374 1.0 0.5 1.1353025933318837
130.0 0.40669672646934574 1.0 0.5 1.0440991764725864
131.0 0.10105613827873039 1.0 0.5 0.21306938341833667
132.0 0.7598058191143243 1.0 0.5 2.852615191501923
133.0 0.7882552857444408 1.0 0.5 3.104747815909758
134.0 0.41196255767852374 1.0 0.5 1.0619293113867083
135.0 0.23956793737837967 1.0 0.5 0.5477370075782519
136.0 0.301117813053034 1.0 0.5 0.716546192187808
137.0 0.4359866364410945 1.0 0.5 1.1453546670228079
138.0 0.9682651399507317 1.0 0.5 6.90067903242789
139.0 0.10678335714273168 1.0 0.5 0.22585225268919112
140.0 0.2693226978676214 1.0 0.5 0.6275667277003328
141.0 0.5668302775070247 1.0 0.5 1.6732513179468083
142.0 0.7096151948853401 1.0 0.5 2.473096642771549
143.0 0.7574375459472653 1.0 0.5 2.8329921185549365
144.0 0.49769652658104957 1.0 0.5 1.3771016264425564
145.0 0.45884572648841415 1.0 0.5 1.2281017543594028
146.0 0.3288386747446713 1.0 0.5 0.7974914915764556
147.0 0.5410136911709724 1.0 0.5 1.557469795251325
148.0 0.6336220553800798 1.0 0.5 2.008179685617141
149.0 0.375647544465191 1.0 0.5 0.9420804749655175
150.0 0.10142418148506294 1.0 0.5 0.21388838577034947
151.0 0.4721728293756773 1.0 0.5 1.2779727544450452
152.0 0.7518331384524283 1.0 0.5 2.787307860488268
153.0 6.676079335730689e-2 1.0 0.5 0.13818745319668635
154.0 0.8053497028664404 1.0 0.5 3.2731013568502365
155.0 0.6436250826649516 1.0 0.5 2.063543927419815
156.0 0.28432165233043427 1.0 0.5 0.6690488961123614
157.0 0.33131329522029473 1.0 0.5 0.8048792646192418
158.0 0.4390246975576103 1.0 0.5 1.1561567971907922
159.0 0.9576167619712271 1.0 0.5 6.322004648835221
160.0 0.2191897706358752 1.0 0.5 0.4948462856734829
161.0 1.1385964425825512e-2 1.0 0.5 2.2902561570486413e-2
162.0 0.679111841181116 1.0 0.5 2.2733252629142697
163.0 0.3189329784940914 1.0 0.5 0.768189122733912
164.0 0.5494024842158357 1.0 0.5 1.5943615282559738
165.0 0.4995339525325778 1.0 0.5 1.3844310395116766
166.0 0.6133797107105055 1.0 0.5 1.900624464472158
167.0 0.18020899363866738 1.0 0.5 0.3974116829996968
168.0 0.3549472573452819 1.0 0.5 0.8768463879435472
169.0 0.6992620601216817 1.0 0.5 2.403032050173198
170.0 0.24085612119427668 1.0 0.5 0.5511279118150403
171.0 0.1609790935708849 1.0 0.5 0.3510393091093769
172.0 0.9711366383834527 1.0 0.5 7.090364504579701
173.0 0.38455734034855193 1.0 0.5 0.9708269965922631
174.0 0.7140149247000265 1.0 0.5 2.503631307579515
175.0 0.6231707003505403 1.0 0.5 1.9519259602967969
176.0 0.6056033420465197 1.0 0.5 1.8607962600766825
177.0 0.9191984318132235 1.0 0.5 5.03151781078248
178.0 0.31549310135748787 1.0 0.5 0.7581131118739614
179.0 0.4450415722231543 1.0 0.5 1.1777241458955992
180.0 0.4583485174404076 1.0 0.5 1.2262650109539877
181.0 0.8948048795370758 1.0 0.5 4.503876726373103
182.0 0.5068846132533013 1.0 0.5 1.4140241642575553
183.0 0.474099338611806 1.0 0.5 1.2852858815130643
184.0 3.968996187382612e-2 1.0 0.5 8.099818055602134e-2
185.0 0.3812923011104965 1.0 0.5 0.9602446657347301
186.0 0.4490455490374048 1.0 0.5 1.1922062787516934
187.0 0.18885603597795153 1.0 0.5 0.4186194528265905
188.0 0.14835262533228888 1.0 0.5 0.32116543464514347
189.0 1.0239721160210324e-2 1.0 0.5 2.0585015521643695e-2
190.0 0.7812863611722196 1.0 0.5 3.0399839801249593
191.0 0.40315501297127665 1.0 0.5 1.032195705046974
192.0 0.27623054102229216 1.0 0.5 0.6465647282627558
193.0 0.3476188563715197 1.0 0.5 0.8542526234724834
194.0 0.40005917714351136 1.0 0.5 1.0218485144052543
195.0 0.690531564629077 1.0 0.5 2.3457983558717395
196.0 0.6243976540207664 1.0 0.5 1.9584485714328679
197.0 0.6936108435709636 1.0 0.5 2.365798463973219
198.0 0.5580754032112615 1.0 0.5 1.6332320139161962
199.0 0.5077201201493545 1.0 0.5 1.4174157254902722
200.0 0.24217287516689856 1.0 0.5 0.5545999737072358
201.0 0.5866156019146013 1.0 0.5 1.7667547458541368
202.0 0.13480908234777678 1.0 0.5 0.289610164710414
203.0 0.8592340571612042 1.0 0.5 3.921313495527709
204.0 0.5015919278028333 1.0 0.5 1.3926722308356132
205.0 0.9524596166650006 1.0 0.5 6.092351507324665
206.0 0.7897861372493181 1.0 0.5 3.1192597448504493
207.0 0.992502482003315 1.0 0.5 9.786366493971752
208.0 0.7190312712917515 1.0 0.5 2.539023803153757
209.0 4.905914294075553e-2 1.0 0.5 0.10060681726863402
210.0 7.292405751548614e-2 1.0 0.5 0.15143958783801956
211.0 0.7448249635342986 1.0 0.5 2.731611103575813
212.0 7.024810923770186e-2 1.0 0.5 0.14567502510922456
213.0 0.6499895525785409 1.0 0.5 2.0995845503371515
214.0 0.2347304081263114 1.0 0.5 0.5350541991171558
215.0 0.5554391604460018 1.0 0.5 1.62133672301354
216.0 0.45655849903065526 1.0 0.5 1.2196664242497346
217.0 0.7734426024060143 1.0 0.5 2.969513910302441
218.0 0.13396935067038884 1.0 0.5 0.28766995842079884
219.0 0.44732092861928796 1.0 0.5 1.1859555740131458
220.0 0.532360601482588 1.0 0.5 1.5201155921058849
221.0 0.8353842261129955 1.0 0.5 3.6082823273928657
222.0 0.4415319449291001 1.0 0.5 1.1651157196663489
223.0 7.107670903097285e-2 1.0 0.5 0.14745823038641734
224.0 0.2587810776672368 1.0 0.5 0.5989185111514972
225.0 0.8783986898097359 1.0 0.5 4.214015069834256
226.0 0.8772054215086009 1.0 0.5 4.194484826673072
227.0 0.8792794678306639 1.0 0.5 4.228554112475122
228.0 0.9704733519907857 1.0 0.5 7.04492420208042
229.0 0.5911949898493493 1.0 0.5 1.7890339688352386
230.0 0.1881415659970821 1.0 0.5 0.4168585927615873
231.0 0.27280409460696464 1.0 0.5 0.6371187335647226
232.0 0.8997405595900834 1.0 0.5 4.599988097103155
233.0 0.805703299381296 1.0 0.5 3.2767378072078768
234.0 0.12469160466325713 1.0 0.5 0.26635800581530467
235.0 4.5007500538482015e-2 1.0 0.5 9.210358499849247e-2
236.0 0.5406049480217902 1.0 0.5 1.5556895188057671
237.0 0.7089850749112344 1.0 0.5 2.4687614483220965
238.0 0.4050350886413143 1.0 0.5 1.038505695363729
239.0 0.18681323647475456 1.0 0.5 0.4135889487659769
240.0 0.23557258393827696 1.0 0.5 0.5372564022794455
241.0 0.32077303736600393 1.0 0.5 0.7735998942749642
242.0 0.27136665743377386 1.0 0.5 0.6331692658855377
243.0 8.600287997937284e-2 1.0 0.5 0.1798557169901321
244.0 0.7600332087019175 1.0 0.5 2.8545094696108473
245.0 0.41783858737032487 1.0 0.5 1.0820150568291664
246.0 0.8293413803867148 1.0 0.5 3.5361801888515507
247.0 0.7333405374926266 1.0 0.5 2.6435657118891944
248.0 0.8772160342203914 1.0 0.5 4.194657687243259
249.0 5.301719603632349e-2 1.0 0.5 0.10894868878842578
250.0 0.9026197915984311 1.0 0.5 4.658264576287863
251.0 0.23914978744357662 1.0 0.5 0.5466375404979962
252.0 0.4968410398019236 1.0 0.5 1.3736982691137887
253.0 0.5384099353933083 1.0 0.5 1.5461561756710942
254.0 0.8907377100572391 1.0 0.5 4.428007915156274
255.0 0.9066080833593035 1.0 0.5 4.741900966190897
256.0 0.6829340520390256 1.0 0.5 2.297290978019848
257.0 0.6571961620790489 1.0 0.5 2.1411937930382208
258.0 0.3669337202760652 1.0 0.5 0.9143603100291875
259.0 0.5097789017273943 1.0 0.5 1.4257975373650602
260.0 0.19359708351354943 1.0 0.5 0.4303435299938143
261.0 0.4198903553742862 1.0 0.5 1.0890763016996372
262.0 0.8275841161941834 1.0 0.5 3.515691583104315
263.0 0.5245014108343904 1.0 0.5 1.486782728111085
264.0 0.20212413144380958 1.0 0.5 0.45160449363942295
265.0 0.6588746438800428 1.0 0.5 2.1510105119936225
266.0 0.6090021282726809 1.0 0.5 1.8781063243284435
267.0 0.8237249377890233 1.0 0.5 3.4714193009141487
268.0 0.39616901908028135 1.0 0.5 1.0089219062444619
269.0 0.46974976524528655 1.0 0.5 1.268812485625708
270.0 0.1430991547459871 1.0 0.5 0.30886613379677225
271.0 0.8900411063855386 1.0 0.5 4.415297354889731
272.0 0.8908538606807918 1.0 0.5 4.430135134053363
273.0 0.7571966906626759 1.0 0.5 2.8310071799990957
274.0 0.45373865486682496 1.0 0.5 1.2093155273309903
275.0 0.5105750301805768 1.0 0.5 1.429048215969818
276.0 0.8703161512938904 1.0 0.5 4.085311447017532
277.0 0.6263910497078812 1.0 0.5 1.9690912320594496
278.0 0.8879229935650624 1.0 0.5 4.377138172983162
279.0 0.4592765782031528 1.0 0.5 1.2296947319737286
280.0 0.3332564208219061 1.0 0.5 0.8106994919909759
281.0 0.7769330816977306 1.0 0.5 3.000566940929362
282.0 0.47688504943059673 1.0 0.5 1.2959080966079761
283.0 0.5519970113210297 1.0 0.5 1.6059107508619763
284.0 0.6116679748262741 1.0 0.5 1.8917891406149387
285.0 0.23344992857646873 1.0 0.5 0.5317105161007432
286.0 0.547367711693101 1.0 0.5 1.5853504174370916
287.0 0.45229676089796134 1.0 0.5 1.2040433464044202
288.0 0.2232542399926749 1.0 0.5 0.5052843787124497
289.0 4.812719615823391e-2 1.0 0.5 9.864772505442727e-2
290.0 0.9924754840764293 1.0 0.5 9.779177599019986
291.0 0.23112957413067814 1.0 0.5 0.525665641185302
292.0 0.7136348699646448 1.0 0.5 2.500975207955907
293.0 0.7097521146725535 1.0 0.5 2.474039888248458
294.0 0.2534528100999812 1.0 0.5 0.584592898262904
295.0 0.14159162922836588 1.0 0.5 0.30535067223059725
296.0 0.286451779155965 1.0 0.5 0.6750105216507689
297.0 0.9194163349443866 1.0 0.5 5.0369186336261
298.0 0.8565261729771216 1.0 0.5 3.8832053010040535
299.0 0.9963446427954837 1.0 0.5 11.223122920363782
300.0 0.44312606197302895 1.0 0.5 1.1708327755623118
301.0 0.3333780003343948 1.0 0.5 0.8110642217087809
302.0 8.100442373331274e-2 1.0 0.5 0.16894794055205103
303.0 0.9114279295358697 1.0 0.5 4.847877405697818
304.0 0.1420851500734669 1.0 0.5 0.30650085385781334
305.0 0.3998938086649432 1.0 0.5 1.0212973077353178
306.0 0.43509561875462044 1.0 0.5 1.1421975977833791
307.0 0.2607501670030833 1.0 0.5 0.6042386923167598
308.0 0.7861629300585208 1.0 0.5 3.0850818187043214
309.0 0.4238639225351366 1.0 0.5 1.1028228011782435
310.0 0.8296205577621936 1.0 0.5 3.5394546320186806
311.0 0.797111503088613 1.0 0.5 3.190197454292849
312.0 4.847906767173793e-2 1.0 0.5 9.93871863877833e-2
313.0 0.2272307227002427 1.0 0.5 0.5155495038419591
314.0 0.28798275880438495 1.0 0.5 0.6793063054019258
315.0 0.9119630135350312 1.0 0.5 4.859996504134525
316.0 0.9247506337150422 1.0 0.5 5.173895593701935
317.0 0.313064117705499 1.0 0.5 0.7510286422175019
318.0 0.10267561230063371 1.0 0.5 0.2166756921335689
319.0 0.7800056454356652 1.0 0.5 3.0283067880604637
320.0 0.9880505590690435 1.0 0.5 8.854141571438799
321.0 0.5199897620784429 1.0 0.5 1.4678956926088331
322.0 0.9631286266437556 1.0 0.5 6.6006396376399366
323.0 0.6526508389996869 1.0 0.5 2.1148495545527686
324.0 0.44331946385558707 1.0 0.5 1.1715274946406817
325.0 0.7657175467075138 1.0 0.5 2.9024556523792184
326.0 0.8587810198761535 1.0 0.5 3.914887085632034
327.0 0.17717500338441594 1.0 0.5 0.39002348344727783
328.0 0.6400146315652561 1.0 0.5 2.043383783189525
329.0 0.5429950331288752 1.0 0.5 1.5661220394400488
330.0 0.1519419896098827 1.0 0.5 0.3296124741021507
331.0 0.2317505808062127 1.0 0.5 0.5272816679676412
332.0 0.9587236527128663 1.0 0.5 6.374931295970532
333.0 0.3957876337227971 1.0 0.5 1.0076590860947048
334.0 0.7520930392631228 1.0 0.5 2.7894035230513716
335.0 0.5219702075466132 1.0 0.5 1.4761644422492128
336.0 0.2718748554726389 1.0 0.5 0.6345646874711566
337.0 0.43339022569610974 1.0 0.5 1.1361688818668743
338.0 0.654264591604089 1.0 0.5 2.124163024174615
339.0 0.21929573754620202 1.0 0.5 0.4951177321724933
340.0 0.6463525037251117 1.0 0.5 2.0789092703893584
341.0 0.40363690799123597 1.0 0.5 1.0338111652659434
342.0 0.5464987531537895 1.0 0.5 1.5815145200909522
343.0 0.2794928368714429 1.0 0.5 0.6555998434128101
344.0 0.9679988160115437 1.0 0.5 6.883964754455241
345.0 0.9374750976583118 1.0 0.5 5.5443807282558
346.0 0.5043382898350185 1.0 0.5 1.403723241814482
347.0 0.37940066231801983 1.0 0.5 0.9541391883810038
348.0 0.16327499528946765 1.0 0.5 0.35651962241911506
349.0 0.6814882638496493 1.0 0.5 2.2881919129060675
350.0 0.7593963453274154 1.0 0.5 2.8492085714581132
351.0 8.2716537875273e-2 1.0 0.5 0.17267747098244784
352.0 0.9864630812678177 1.0 0.5 8.604669210362268
353.0 0.10362777838201431 1.0 0.5 0.2187990527194605
354.0 0.3018065167087475 1.0 0.5 0.7185180358786611
355.0 0.1981827289480086 1.0 0.5 0.4417490773130338
356.0 0.2519352721846343 1.0 0.5 0.5805315404780675
357.0 0.37720491978724313 1.0 0.5 0.947075477038406
358.0 3.334532342207808e-2 1.0 0.5 6.782791058537331e-2
359.0 0.49142274606532255 1.0 0.5 1.3522762997820723
360.0 0.7658697744126436 1.0 0.5 2.9037555976399063
361.0 0.430584327777621 1.0 0.5 1.1262891608345273
362.0 0.18774246417057594 1.0 0.5 0.41587565350859623
363.0 0.43213770208564395 1.0 0.5 1.131752645804099
364.0 0.5254311249185892 1.0 0.5 1.4906970370036838
365.0 0.21632961088151903 1.0 0.5 0.48753353815321687
366.0 0.5866314734106438 1.0 0.5 1.766831535403086
367.0 0.2127018826329221 1.0 0.5 0.47829660009371444
368.0 0.762880957964817 1.0 0.5 2.8783859537652954
369.0 0.7092177159493649 1.0 0.5 2.4703609132000657
370.0 0.4668447454243504 1.0 0.5 1.25788522569854
371.0 8.984189541128584e-2 1.0 0.5 0.18827390651246967
372.0 0.8401841637115331 1.0 0.5 3.6674662997626886
373.0 0.1769541258232804 1.0 0.5 0.3894866793361383
374.0 0.32759234424821526 1.0 0.5 0.793780983603854
375.0 0.7549436630804378 1.0 0.5 2.812534296521244
376.0 0.5406091390043264 1.0 0.5 1.5557077645471398
377.0 7.226167164454322e-2 1.0 0.5 0.15001111942581233
378.0 3.9174989741246e-2 1.0 0.5 7.992595578900699e-2
379.0 0.43530038855865494 1.0 0.5 1.1429227007667369
380.0 0.19425051459560916 1.0 0.5 0.4319647938819565
381.0 0.2690512431721227 1.0 0.5 0.6268238435762967
382.0 0.6122531354155542 1.0 0.5 1.894805126272543
383.0 0.8144904991435312 1.0 0.5 3.3692983613822673
384.0 0.44435200950498954 1.0 0.5 1.1752405917023965
385.0 0.40334065577595324 1.0 0.5 1.0328178822819034
386.0 0.6712465016160815 1.0 0.5 2.2248941081495746
387.0 0.610470870145168 1.0 0.5 1.8856332573010395
388.0 0.3753417849616416 1.0 0.5 0.941101269529212
389.0 0.5760552709957159 1.0 0.5 1.7163043767384967
390.0 0.8958499208801377 1.0 0.5 4.523844703206438
391.0 0.6375933030298327 1.0 0.5 2.0299764509716054
392.0 0.4996734547364764 1.0 0.5 1.3849886064074164
393.0 0.43886175915693537 1.0 0.5 1.1555759704008648
394.0 2.1262190388847357e-2 1.0 0.5 4.298297362707392e-2
395.0 0.2612612193574123 1.0 0.5 0.6056217946491596
396.0 0.9053544127651678 1.0 0.5 4.715232048676575
397.0 5.715293130681975e-3 1.0 0.5 1.146337583128797e-2
398.0 0.2947471489241186 1.0 0.5 0.6983977729250015
399.0 8.460986179878727e-2 1.0 0.5 0.17680984806639513
400.0 0.30069220409765574 1.0 0.5 0.7153285923659113
401.0 0.997746334354857 1.0 0.5 12.190394425627364
402.0 0.18308241899251243 1.0 0.5 0.40443413850132504
403.0 0.3105228234689785 1.0 0.5 0.7436433675489958
404.0 0.9179013483983409 1.0 0.5 4.999667373023489
405.0 0.11926274283498617 1.0 0.5 0.2539918600578725
406.0 0.43776630003690786 1.0 0.5 1.1516753585822221
407.0 0.4762249664302428 1.0 0.5 1.2933860241922412
408.0 0.8482098508688078 1.0 0.5 3.770512619720418
409.0 0.4567392533274949 1.0 0.5 1.2203317557106708
410.0 0.4435608409662263 1.0 0.5 1.1723948842501484
411.0 0.50408147116895 1.0 0.5 1.4026872442755594
412.0 0.36104698819880265 1.0 0.5 0.8958487225315878
413.0 0.4194713065185254 1.0 0.5 1.0876321003142069
414.0 7.486133824518293e-2 1.0 0.5 0.1556232962089628
415.0 3.373382017468085e-2 1.0 0.5 6.863186850542395e-2
416.0 0.4932147269781292 1.0 0.5 1.3593357794290557
417.0 0.8616586394474591 1.0 0.5 3.956062042024912
418.0 0.4117184281160471 1.0 0.5 1.0610991639078917
419.0 9.116459643129304e-2 1.0 0.5 0.19118255076481538
420.0 0.5890322019489482 1.0 0.5 1.7784808355923856
421.0 0.43778596825837024 1.0 0.5 1.1517453243828897
422.0 0.5541973559190224 1.0 0.5 1.6157578539111792
423.0 0.5236632829365838 1.0 0.5 1.4832605720870944
424.0 0.6204546477584022 1.0 0.5 1.9375623680773675
425.0 0.970316394356556 1.0 0.5 7.034320768236008
426.0 0.43993687089356626 1.0 0.5 1.1594115421186992
427.0 0.8405879195529187 1.0 0.5 3.6725254570044403
428.0 0.749280638128116 1.0 0.5 2.766842091120008
429.0 0.5488427514547121 1.0 0.5 1.5918786677038552
430.0 0.13747140435906435 1.0 0.5 0.29577395251982774
431.0 0.4576343120245375 1.0 0.5 1.2236296079783713
432.0 0.8148665411500688 1.0 0.5 3.3733566295966297
433.0 0.19547202902357552 1.0 0.5 0.4349990900088173
434.0 0.4890095869756548 1.0 0.5 1.3428089003184602
435.0 0.12715136653541503 1.0 0.5 0.27198624962848195
436.0 0.2032311331013058 1.0 0.5 0.45438129228481317
437.0 0.8787527473448604 1.0 0.5 4.21984681587113
438.0 0.4663010675042861 1.0 0.5 1.2558467916792808
439.0 0.3142004342512348 1.0 0.5 0.7543397443148356
440.0 0.5376680285543044 1.0 0.5 1.5429441860463613
441.0 0.8288823435429962 1.0 0.5 3.530807819241641
442.0 0.5381362365823195 1.0 0.5 1.5449706315293206
443.0 0.8741054855972965 1.0 0.5 4.144621819895548
444.0 0.9650736097727945 1.0 0.5 6.709025137110639
445.0 8.401495565683514e-2 1.0 0.5 0.17551048315515766
446.0 0.16014272925069362 1.0 0.5 0.34904663471346736
447.0 0.6761260538348454 1.0 0.5 2.254801787874353
448.0 0.30491746315485757 1.0 0.5 0.7274493648359186
449.0 0.8823536465498564 1.0 0.5 4.280144318376048
450.0 0.35138375129442345 1.0 0.5 0.8658280669121068
451.0 0.8162562408450885 1.0 0.5 3.388426210497536
452.0 0.673617698352461 1.0 0.5 2.2393717605117374
453.0 8.256976107323988e-2 1.0 0.5 0.1723574716228483
454.0 0.8365768515057421 1.0 0.5 3.6228248778772634
455.0 0.48971308441437955 1.0 0.5 1.3455642637453662
456.0 8.774182190296687e-2 1.0 0.5 0.18366447790309529
457.0 0.24099238723353444 1.0 0.5 0.5514869432829278
458.0 0.5907862348164701 1.0 0.5 1.787035212429029
459.0 0.9282830732565702 1.0 0.5 5.270056963848408
460.0 0.32874248016649343 1.0 0.5 0.7972048609806637
461.0 0.7759823021398251 1.0 0.5 2.9920604438874734
462.0 0.9906880008613337 1.0 0.5 9.352902960980467
463.0 0.35519401347986057 1.0 0.5 0.8776116070547805
464.0 0.22036578800170115 1.0 0.5 0.4978608565413814
465.0 0.8023870524533302 1.0 0.5 3.242889943586732
466.0 0.6555700243159146 1.0 0.5 2.131728945611721
467.0 0.6966117625572236 1.0 0.5 2.385483963919468
468.0 0.31199672354331665 1.0 0.5 0.7479233575368842
469.0 0.10874684309305482 1.0 0.5 0.23025353029665035
470.0 0.7768279542152332 1.0 0.5 2.999624598436637
471.0 0.5194659966765868 1.0 0.5 1.465714573067321
472.0 3.387321287945699e-2 1.0 0.5 6.892040754981558e-2
473.0 0.9137616097231142 1.0 0.5 4.901279675232361
474.0 0.9310800753319032 1.0 0.5 5.349619920714008
475.0 0.8956753753595035 1.0 0.5 4.520495700986587
476.0 0.9734569283996768 1.0 0.5 7.257973044045264
477.0 0.3100378260015375 1.0 0.5 0.7422370063712049
478.0 0.9004067891568347 1.0 0.5 4.613322561880238
479.0 0.3595142946826074 1.0 0.5 0.8910569518000615
480.0 0.5858555389814262 1.0 0.5 1.7630808527274318
481.0 0.7207027332090898 1.0 0.5 2.5509571840094765
482.0 0.5207773901843563 1.0 0.5 1.4711801017479904
483.0 0.5010641338355079 1.0 0.5 1.3905554324221692
484.0 0.7386177898402442 1.0 0.5 2.683543072229971
485.0 0.7514865091276058 1.0 0.5 2.784516291388268
486.0 0.996791280204512 1.0 0.5 11.48376647798819
487.0 0.31973896223026976 1.0 0.5 0.7705573508031445
488.0 0.5409498257000886 1.0 0.5 1.557191525390985
489.0 0.2351915468213719 1.0 0.5 0.5362597290194078
490.0 0.5722823786456511 1.0 0.5 1.6985841286612482
491.0 0.8872393295593034 1.0 0.5 4.364975334044577
492.0 0.7466377111677412 1.0 0.5 2.745869685758634
493.0 0.8944045014489479 1.0 0.5 4.496279071952017
494.0 0.7761279146229962 1.0 0.5 2.993360875321733
495.0 6.282087728304298e-4 1.0 0.5 1.2568123572811955e-3
496.0 2.1755806290161828e-2 1.0 0.5 4.399190658802096e-2
497.0 0.25822043228050306 1.0 0.5 0.5974063169929631
498.0 0.36706789505445514 1.0 0.5 0.9147842435207847
499.0 0.8535706465084604 1.0 0.5 3.8424243911227456
500.0 0.9583607379261688 1.0 0.5 6.357423513924509
501.0 0.1736332737734787 1.0 0.5 0.38143325101594394
502.0 0.7191057722209122 1.0 0.5 2.539554188214649
503.0 0.5866772207662699 1.0 0.5 1.7670528869782172
504.0 0.44342504955089734 1.0 0.5 1.171906870972165
505.0 0.8638825079861409 1.0 0.5 3.988473708673089
506.0 0.19206484030065873 1.0 0.5 0.42654694315586256
507.0 6.329398370441452e-2 1.0 0.5 0.1307715918497558
508.0 0.8324305296152746 1.0 0.5 3.5727145302718077
509.0 0.788341172013531 1.0 0.5 3.105559205156182
510.0 0.9968069620813552 1.0 0.5 11.493564979531474
511.0 0.5738675981141458 1.0 0.5 1.70601035690584
512.0 2.1924901743684888e-2 1.0 0.5 4.433764862438196e-2
513.0 0.31475857342097047 1.0 0.5 0.755968110508673
514.0 0.5840924030390661 1.0 0.5 1.7545843321676697
515.0 0.7770937124350712 1.0 0.5 3.0020076619607927
516.0 0.7130309607190969 1.0 0.5 2.496761892223379
517.0 0.3991683439699586 1.0 0.5 1.0188809802465286
518.0 0.48509787688675254 1.0 0.5 1.3275568971757934
519.0 0.45169086393350866 1.0 0.5 1.2018320683571915
520.0 0.12902719463817103 1.0 0.5 0.2762890498682689
521.0 0.2592134704552379 1.0 0.5 0.6000855589507411
522.0 0.2813001484016546 1.0 0.5 0.660622921987986
523.0 0.3762566475369137 1.0 0.5 0.9440325786940167
524.0 0.9267694189625785 1.0 0.5 5.228284343045507
525.0 0.15197347800388006 1.0 0.5 0.32968673548099053
526.0 0.14593597548755854 1.0 0.5 0.3154982356972103
527.0 0.35991105880863383 1.0 0.5 0.8922962833448616
528.0 0.3071108301936344 1.0 0.5 0.7337704414228866
529.0 0.18406488587857806 1.0 0.5 0.40684088837547255
530.0 0.5136711150110314 1.0 0.5 1.4417403317355608
531.0 0.6056599490894785 1.0 0.5 1.8610833370818218
532.0 0.44302266378392197 1.0 0.5 1.1704614578045645
533.0 0.7453946147476727 1.0 0.5 2.736080882533261
534.0 0.35502683979054106 1.0 0.5 0.8770931502610587
535.0 0.8797839338461947 1.0 0.5 4.236929207935352
536.0 6.238712029644411e-2 1.0 0.5 0.12883624673709432
537.0 0.9424758304767943 1.0 0.5 5.711100159925468
538.0 0.5704103694439081 1.0 0.5 1.689849747036119
539.0 0.9158448954522559 1.0 0.5 4.950187400162322
540.0 0.8873811703242918 1.0 0.5 4.367492702015337
541.0 0.6216382152888731 1.0 0.5 1.9438088773652653
542.0 0.48827370203072595 1.0 0.5 1.3399307423143256
543.0 0.4572473011375716 1.0 0.5 1.2222029953319737
544.0 3.967393021768029e-2 1.0 0.5 8.096479233410842e-2
545.0 0.29505351687188286 1.0 0.5 0.6992667790155687
546.0 0.5639878272499856 1.0 0.5 1.6601702337428519
547.0 0.48965142848521204 1.0 0.5 1.3453226263340796
548.0 0.8749613569725964 1.0 0.5 4.15826489047167
549.0 0.9256239598413039 1.0 0.5 5.19724285977426
550.0 0.7569605924580269 1.0 0.5 2.8290633556705096
551.0 0.3844172120051691 1.0 0.5 0.9703716742615802
552.0 0.1362858511639865 1.0 0.5 0.29302682234878386
553.0 0.37983323803435165 1.0 0.5 0.9555337323937093
554.0 0.26566735487098103 1.0 0.5 0.6175863160615908
555.0 0.36961293921650573 1.0 0.5 0.9228425321120206
556.0 9.63913755811967e-2 1.0 0.5 0.2027178998486325
557.0 0.18788147800222665 1.0 0.5 0.4162179728411676
558.0 0.26504942094508055 1.0 0.5 0.6159040428220617
559.0 0.739578089934357 1.0 0.5 2.6909044643005315
560.0 0.6457524310661318 1.0 0.5 2.075518526013794
561.0 0.9092071659989257 1.0 0.5 4.798349834364611
562.0 0.210969342425946 1.0 0.5 0.4739002053005348
563.0 0.9875371965277739 1.0 0.5 8.770013586320161
564.0 5.026001823606596e-2 1.0 0.5 0.10313407051509839
565.0 0.12100530799389475 1.0 0.5 0.2579528399771316
566.0 0.5890018173984741 1.0 0.5 1.7783329727795534
567.0 0.7224532694248171 1.0 0.5 2.563531923007902
568.0 0.8883622267112601 1.0 0.5 4.384991631947751
569.0 1.997234871111797e-2 1.0 0.5 4.0348984229344e-2
570.0 0.2212019516532856 1.0 0.5 0.5000070229243507
571.0 0.4273320266042193 1.0 0.5 1.1148983665533385
572.0 0.9981606891187609 1.0 0.5 12.596728597154938
573.0 0.24173972097342367 1.0 0.5 0.5534571525106269
574.0 0.30996923292210077 1.0 0.5 0.7420381848339302
575.0 0.5586292644735815 1.0 0.5 1.635740173145147
576.0 0.5710479605847417 1.0 0.5 1.6928203250772282
577.0 0.7716668116970227 1.0 0.5 2.953898729115331
578.0 0.1347753271289409 1.0 0.5 0.2895321367059855
579.0 0.7338594799945437 1.0 0.5 2.647461677978153
580.0 0.11653928663743118 1.0 0.5 0.2478169105193333
581.0 0.939970706008818 1.0 0.5 5.6258452054414265
582.0 0.6523955046706064 1.0 0.5 2.1133799063928125
583.0 0.8032152138335183 1.0 0.5 3.2512892068337553
584.0 0.6707576127357098 1.0 0.5 2.22192212014176
585.0 0.706492182007378 1.0 0.5 2.451702005911791
586.0 0.7647771000645677 1.0 0.5 2.894443408052288
587.0 0.8173666289040515 1.0 0.5 3.400549144677044
588.0 0.21872300084295448 1.0 0.5 0.49365103921530656
589.0 0.7310001086753175 1.0 0.5 2.626088606755685
590.0 0.8697372961374548 1.0 0.5 4.076404137303028
591.0 0.16400157324713815 1.0 0.5 0.35825709554754664
592.0 0.443313209241608 1.0 0.5 1.1715050236598006
593.0 0.8053657385685586 1.0 0.5 3.2732661278566844
594.0 0.30079618388942353 1.0 0.5 0.7156259936633084
595.0 0.45365879994299696 1.0 0.5 1.2090231797639022
596.0 0.8069809893677921 1.0 0.5 3.2899331884862204
597.0 0.8245884511775761 1.0 0.5 3.4812407168767363
598.0 0.41234621682526684 1.0 0.5 1.063234617242673
599.0 0.7968250346184004 1.0 0.5 3.1873755454599793
600.0 0.3927417451741644 1.0 0.5 0.9976022348148476
601.0 0.2728256265562098 1.0 0.5 0.6371779535572102
602.0 8.203703710226784e-2 1.0 0.5 0.1711964692057045
603.0 0.37776869105901545 1.0 0.5 0.9488867520931888
604.0 0.629411417011517 1.0 0.5 1.9853255448725573
605.0 0.7501910378551001 1.0 0.5 2.774117609305619
606.0 0.5996333900313177 1.0 0.5 1.8307492534099181
607.0 6.970492186242305e-2 1.0 0.5 0.14450690968030883
608.0 0.8940723635978487 1.0 0.5 4.489998186900931
609.0 0.6914380476986998 1.0 0.5 2.3516652759309613
610.0 0.3650550811756098 1.0 0.5 0.9084340517211708
611.0 6.128389132423373e-2 1.0 0.5 0.12648435832908939
612.0 0.7680345331232672 1.0 0.5 2.9223335361285874
613.0 0.23058140936561866 1.0 0.5 0.5242402528938145
614.0 0.18527936511039267 1.0 0.5 0.40982000756014936
615.0 0.28710359124883345 1.0 0.5 0.676838316784801
616.0 0.2108511727487865 1.0 0.5 0.4736006964588179
617.0 0.4624966724507077 1.0 0.5 1.241640656420202
618.0 0.9811961480020145 1.0 0.5 7.947387073248349
619.0 0.8245811182215507 1.0 0.5 3.4811571100355176
620.0 0.8168888824501829 1.0 0.5 3.3953242213722077
621.0 0.6208021859846258 1.0 0.5 1.9393945466905502
622.0 0.6514815007857316 1.0 0.5 2.108127935592991
623.0 0.8002695403068458 1.0 0.5 3.221573045869622
624.0 0.44461502006124476 1.0 0.5 1.176187496315193
625.0 0.24944701714221795 1.0 0.5 0.5738900673091492
626.0 0.15074825367641687 1.0 0.5 0.32679923126166255
627.0 0.48159464793185214 1.0 0.5 1.3139956195836684
628.0 0.7293846186875164 1.0 0.5 2.614113446702638
629.0 0.22027782974542087 1.0 0.5 0.49763522946247984
630.0 0.20798244662851184 1.0 0.5 0.46634344813095197
631.0 0.6919106866218325 1.0 0.5 2.354731119087316
632.0 0.9720879966592072 1.0 0.5 7.1573969108149464
633.0 0.9555225762947214 1.0 0.5 6.2255471020245
634.0 0.9266176357074408 1.0 0.5 5.22414328144902
635.0 0.3345233531787639 1.0 0.5 0.8145034658807747
636.0 0.718429616730576 1.0 0.5 2.5347456665564865
637.0 0.8878295863454977 1.0 0.5 4.375472027171012
638.0 0.3092083755044568 1.0 0.5 0.7398341142762942
639.0 0.7848160471899103 1.0 0.5 3.0725240444024844
640.0 0.4053789118552892 1.0 0.5 1.0396618058885414
641.0 0.7411589342475445 1.0 0.5 2.7030821027672483
642.0 0.45881127046875336 1.0 0.5 1.2279744157261765
643.0 0.22682375665456067 1.0 0.5 0.5144965144587033
644.0 0.16776368155499566 1.0 0.5 0.3672776837982627
645.0 0.5154869010668474 1.0 0.5 1.449221624070085
646.0 0.34454745235530915 1.0 0.5 0.8448587389647154
647.0 0.7272962306454143 1.0 0.5 2.5987383337541456
648.0 0.9326344100560882 1.0 0.5 5.395241852776035
649.0 0.29777872274027883 1.0 0.5 0.7070134297056129
650.0 0.9174126215561729 1.0 0.5 4.987796826948644
651.0 4.5376575536940744e-2 1.0 0.5 9.28766723998495e-2
652.0 0.4810458793989424 1.0 0.5 1.3118795986726604
653.0 0.2950958156948137 1.0 0.5 0.6993867883865484
654.0 0.2212183176044329 1.0 0.5 0.5000490521080256
655.0 0.8206110378697538 1.0 0.5 3.436397715675071
656.0 0.5629205916000906 1.0 0.5 1.6552807756173478
657.0 0.6994457934362445 1.0 0.5 2.4042543067509254
658.0 0.9830737705685453 1.0 0.5 8.15778164570834
659.0 0.8325491011982105 1.0 0.5 3.5741302243464643
660.0 0.2556320014497683 1.0 0.5 0.5904394894534792
661.0 0.5735719811333211 1.0 0.5 1.7046233960032402
662.0 0.3675775710486384 1.0 0.5 0.916395415751471
663.0 0.34003954250576196 1.0 0.5 0.8311507172880653
664.0 0.11876686109163148 1.0 0.5 0.2528661163846483
665.0 0.4006303818268926 1.0 0.5 1.0237536248988528
666.0 0.6505245015357007 1.0 0.5 2.10264364860553
667.0 0.10086413330967303 1.0 0.5 0.21264225003430867
668.0 0.5732670526062165 1.0 0.5 1.7031937546945186
669.0 0.11878163120957308 1.0 0.5 0.25289963814199007
670.0 0.10072655638961314 1.0 0.5 0.21233625313017732
671.0 0.5618155656093103 1.0 0.5 1.6502307483050531
672.0 0.4500194541428453 1.0 0.5 1.1957447451000092
673.0 0.3981179573374246 1.0 0.5 1.0153875905870227
674.0 0.3056380605496083 1.0 0.5 0.7295238556749573
675.0 0.30445908406220024 1.0 0.5 0.7261308796389632
676.0 0.3632627258496999 1.0 0.5 0.9027963019039356
677.0 0.9360322656138116 1.0 0.5 5.49875294592944
678.0 9.829392285480298e-2 1.0 0.5 0.20693333769178202
679.0 0.16857186470900742 1.0 0.5 0.3692208237524054
680.0 0.6851865756088779 1.0 0.5 2.3115502383155535
681.0 6.0746870332459846e-2 1.0 0.5 0.12534052488294534
682.0 0.13633830378369793 1.0 0.5 0.29314828432216455
683.0 7.392456123744273e-2 1.0 0.5 0.15359916061613507
684.0 0.5086610045902572 1.0 0.5 1.4212419421338762
685.0 6.49975666739836e-2 1.0 0.5 0.13441229441823688
686.0 0.5965150506093662 1.0 0.5 1.8152321842298589
687.0 0.4605739048163946 1.0 0.5 1.2344989825581794
688.0 6.864473076963751e-2 1.0 0.5 0.14222894978542783
689.0 0.8344360964556317 1.0 0.5 3.596796069113207
690.0 8.732363913477414e-2 1.0 0.5 0.18274788003816578
691.0 0.21142843578856352 1.0 0.5 0.4750642335181355
692.0 0.7222864812254323 1.0 0.5 2.56233040927018
693.0 0.8184225707114926 1.0 0.5 3.41214621719645
694.0 0.21034070512424763 1.0 0.5 0.4723073977097867
695.0 0.3162647360277784 1.0 0.5 0.7603689545111227
696.0 0.790802361192664 1.0 0.5 3.1289516672537636
697.0 0.13344125555833664 1.0 0.5 0.28645075407773934
698.0 0.7007503099963927 1.0 0.5 2.4129539409113554
699.0 0.9187168349404677 1.0 0.5 5.019632711418354
700.0 0.4599361344660652 1.0 0.5 1.2321357538196342
701.0 0.27682148640453996 1.0 0.5 0.6481983610575905
702.0 1.800784163218272e-3 1.0 0.5 3.604815048388172e-3
703.0 0.7228478637519237 1.0 0.5 2.566377390466142
704.0 0.2985911645520416 1.0 0.5 0.7093286889612735
705.0 0.17315276773821076 1.0 0.5 0.38027065243919844
706.0 0.14367496112886713 1.0 0.5 0.3102105132154968
707.0 0.8032824900526222 1.0 0.5 3.2519730780123863
708.0 0.9263217228455575 1.0 0.5 5.216094540240102
709.0 0.14390022398042068 1.0 0.5 0.3107366977250743
710.0 0.16040391518009045 1.0 0.5 0.349668708391516
711.0 0.23371462343815053 1.0 0.5 0.5324012487287254
712.0 0.5919728166898646 1.0 0.5 1.7928429620744737
713.0 0.103304290572939 1.0 0.5 0.2180774117665795
714.0 0.9472027518538018 1.0 0.5 5.8825924161427
715.0 2.606352915311938e-2 1.0 0.5 5.2818404940095244e-2
716.0 0.3644003382289155 1.0 0.5 0.9063727529217371
717.0 0.8078186466096073 1.0 0.5 3.298631607703358
718.0 0.945005788294678 1.0 0.5 5.801054682018765
719.0 0.3026751927307447 1.0 0.5 0.7210079384190151
720.0 0.13192709639852174 1.0 0.5 0.28295915504898594
721.0 0.2566043774869836 1.0 0.5 0.5930538192083015
722.0 0.10698594605754641 1.0 0.5 0.22630592066398597
723.0 0.6145249789812167 1.0 0.5 1.9065577687955066
724.0 8.930234303466789e-2 1.0 0.5 0.18708863439196044
725.0 0.5078727259176272 1.0 0.5 1.4180358175685772
726.0 0.6074906579312169 1.0 0.5 1.87038988118759
727.0 0.4328926795524597 1.0 0.5 1.1344134309597795
728.0 0.9199649411490993 1.0 0.5 5.0505810093383765
729.0 0.9554407909442231 1.0 0.5 6.221872867230832
730.0 0.25047456653555367 1.0 0.5 0.5766300562133851
731.0 0.8421247486490246 1.0 0.5 3.6919002124484552
732.0 7.259025420929721e-2 1.0 0.5 0.15071959671184512
733.0 0.11620186500134255 1.0 0.5 0.24705319299034392
734.0 0.30850615207588095 1.0 0.5 0.7378020492564494
735.0 0.1883626739567803 1.0 0.5 0.4174033627979661
736.0 0.6623776199438104 1.0 0.5 2.171654453643791
737.0 0.11290896034135722 1.0 0.5 0.2396153284366351
738.0 0.7422642656298815 1.0 0.5 2.7116410087728458
739.0 0.7587318490143916 1.0 0.5 2.8436926086943526
740.0 0.530336944600492 1.0 0.5 1.5114794895629295
741.0 0.6223687487469611 1.0 0.5 1.9476741705662395
742.0 0.5630377543656311 1.0 0.5 1.6558169640962446
743.0 0.6774789767908294 1.0 0.5 2.2631739132509616
744.0 0.7134140595880138 1.0 0.5 2.499433642548651
745.0 0.10002976757404214 1.0 0.5 0.2107871825741759
746.0 0.567848281252265 1.0 0.5 1.677957103179304
747.0 0.4060863958044679 1.0 0.5 1.0420428353605442
748.0 9.50513656846318e-2 1.0 0.5 0.19975418911112916
749.0 0.16631249236543122 1.0 0.5 0.36379327584656745
750.0 0.8411217147036525 1.0 0.5 3.6792337423769124
751.0 0.8261179212585096 1.0 0.5 3.49875583579596
752.0 2.270068052664842e-2 1.0 0.5 4.5924615942012824e-2
753.0 0.794409914691346 1.0 0.5 3.163741939541678
754.0 9.042111886289728e-2 1.0 0.5 0.18954710912519077
755.0 0.8703489330265705 1.0 0.5 4.0858170747733435
756.0 0.4310407173673936 1.0 0.5 1.1278928138744269
757.0 0.3363067143343986 1.0 0.5 0.819870310803085
758.0 0.5130758701244038 1.0 0.5 1.4392939176921202
759.0 0.7908192098998476 1.0 0.5 3.1291127530653498
760.0 0.13285818054236243 1.0 0.5 0.28510548131242014
761.0 0.20374760571336736 1.0 0.5 0.45567813029380005
762.0 0.5394576445781261 1.0 0.5 1.5507009009747217
763.0 6.022815649686475e-2 1.0 0.5 0.12423630571358278
764.0 6.998298713513784e-2 1.0 0.5 0.1451047991981602
765.0 0.8970007092256013 1.0 0.5 4.546066352923313
766.0 0.4229521552684008 1.0 0.5 1.0996601921991296
767.0 0.8670835830456738 1.0 0.5 4.036069584532981
768.0 0.4225403174878275 1.0 0.5 1.0982333057100466
769.0 0.7514278370027265 1.0 0.5 2.784044162493016
770.0 0.3166625910490667 1.0 0.5 0.7615330624342808
771.0 0.35844011299274825 1.0 0.5 0.8877054892696948
772.0 0.6478614003000068 1.0 0.5 2.08746086347037
773.0 0.7201698321036184 1.0 0.5 2.547144806123709
774.0 0.36834307496040686 1.0 0.5 0.9188177447070995
775.0 0.8093749686530289 1.0 0.5 3.3148939343546955
776.0 0.11152824342387613 1.0 0.5 0.2365048393033555
777.0 0.8664817488175403 1.0 0.5 4.027034195017947
778.0 0.5335069631739435 1.0 0.5 1.525024370448048
779.0 0.3938842132094552 1.0 0.5 1.0013684877054532
780.0 0.10183253557450678 1.0 0.5 0.21479748413816208
781.0 8.053929148343719e-2 1.0 0.5 0.16793593441701318
782.0 0.6987324536890543 1.0 0.5 2.39951310171572
783.0 0.9652504478720477 1.0 0.5 6.719177190917287
784.0 8.352182889441673e-2 1.0 0.5 0.17443405931174336
785.0 0.6848311037778758 1.0 0.5 2.309293210731784
786.0 0.8753831237435886 1.0 0.5 4.165022476660053
787.0 0.5017501580403889 1.0 0.5 1.3933072741604589
788.0 0.5164740417097261 1.0 0.5 1.4533005544713893
789.0 5.34146726412843e-3 1.0 0.5 1.0711567808793232e-2
790.0 0.3318023439651666 1.0 0.5 0.8063425138905206
791.0 0.8980158281288398 1.0 0.5 4.565875310945801
792.0 0.3077912787425361 1.0 0.5 0.7357354970569514
793.0 8.244870505377133e-2 1.0 0.5 0.1720935866356492
794.0 0.9525163323404254 1.0 0.5 6.09473893162687
795.0 0.8150156026591003 1.0 0.5 3.37496759231672
796.0 0.6942073379694466 1.0 0.5 2.3696959635020733
797.0 0.3064154871080699 1.0 0.5 0.7317643647045484
798.0 0.6766043921266462 1.0 0.5 2.257757826055945
799.0 0.8850082431583656 1.0 0.5 4.325789665651913
800.0 0.390824501859813 1.0 0.5 0.9912977570009057
801.0 0.9277232680571199 1.0 0.5 5.254506056261732
802.0 0.9515352841551716 1.0 0.5 6.0538385083107515
803.0 0.931339195694947 1.0 0.5 5.3571535534070165
804.0 0.41693501872311356 1.0 0.5 1.078913277353363
805.0 0.9925072396884476 1.0 0.5 9.787636032854072
806.0 0.6270345104129288 1.0 0.5 1.9725387696659187
807.0 0.9026186077418837 1.0 0.5 4.658240262325699
808.0 0.9572829405210631 1.0 0.5 6.306313838242294
809.0 0.3836448542598979 1.0 0.5 0.9678638925777285
810.0 0.9149835758010022 1.0 0.5 4.929821630573945
811.0 0.9650769640332738 1.0 0.5 6.70921722232391
812.0 0.8333633906893451 1.0 0.5 3.5838796592561692
813.0 0.4659441674707303 1.0 0.5 1.254509780378417
814.0 0.6644565585399186 1.0 0.5 2.1840076964202977
815.0 0.5950530445808047 1.0 0.5 1.8079983894541376
816.0 0.6963681256453612 1.0 0.5 2.383878501957269
817.0 0.7577963228381738 1.0 0.5 2.835952531284403
818.0 5.205609640929987e-2 1.0 0.5 0.10691990381092617
819.0 0.266407912351019 1.0 0.5 0.6196042874911304
820.0 0.2334514658552196 1.0 0.5 0.5317145270071396
821.0 0.3750267027666355 1.0 0.5 0.9400927091701334
822.0 0.6114309357827568 1.0 0.5 1.8905687070019104
823.0 0.15551257370829796 1.0 0.5 0.338050863566619
824.0 0.23813670768097417 1.0 0.5 0.5439762915924459
825.0 0.870266707449991 1.0 0.5 4.084549063402345
826.0 3.154053223157938e-2 1.0 0.5 6.409729506779938e-2
827.0 0.1696763468222191 1.0 0.5 0.3718794212240955
828.0 0.9382537256649148 1.0 0.5 5.5694432798975
829.0 0.5690815690817298 1.0 0.5 1.6836729243990005
830.0 0.40173525398781396 1.0 0.5 1.027443807837522
831.0 0.37414920622824466 1.0 0.5 0.9372865697980035
832.0 0.8470235035676409 1.0 0.5 3.75494197495865
833.0 0.1639959478716596 1.0 0.5 0.35824363773142587
834.0 0.8417875076966232 1.0 0.5 3.6876325230218985
835.0 4.4800017902082656e-2 1.0 0.5 9.166911017102182e-2
836.0 8.371841878440967e-2 1.0 0.5 0.17486311694572496
837.0 0.792681678313694 1.0 0.5 3.1469997619491537
838.0 0.70931724616291 1.0 0.5 2.4710455990059654
839.0 0.9536753385934513 1.0 0.5 6.14416163184868
840.0 0.9602885160673758 1.0 0.5 6.452229730589149
841.0 0.7554874920826832 1.0 0.5 2.8169776284993024
842.0 0.13372214044518893 1.0 0.5 0.28709913578589247
843.0 0.5137668062151739 1.0 0.5 1.442133895114351
844.0 0.7646430480436962 1.0 0.5 2.893303945544842
845.0 0.737797471240314 1.0 0.5 2.677276126613299
846.0 0.2757355366840477 1.0 0.5 0.64519734494416
847.0 0.9070120314664122 1.0 0.5 4.750570329609125
848.0 0.8891902056378072 1.0 0.5 4.399880223610048
849.0 0.6345074545436008 1.0 0.5 2.0130187909368447
850.0 0.7278594124350969 1.0 0.5 2.602872960335896
851.0 0.7746614730325766 1.0 0.5 2.9803028864018035
852.0 0.1615769961852126 1.0 0.5 0.35246505607116085
853.0 0.791392456147658 1.0 0.5 3.134601145736619
854.0 0.6680598448264417 1.0 0.5 2.2056011636299084
855.0 8.13464244932427e-3 1.0 0.5 1.63358183694174e-2
856.0 0.10662505504031572 1.0 0.5 0.2254978301028323
857.0 0.9560295924470773 1.0 0.5 6.248476853892508
858.0 0.852060175832956 1.0 0.5 3.821899362730954
859.0 0.9719898411238275 1.0 0.5 7.150376035205891
860.0 0.2712547072167808 1.0 0.5 0.6328620012818229
861.0 0.5288209915498573 1.0 0.5 1.5050343935333608
862.0 0.7664883160339533 1.0 0.5 2.909046329453154
863.0 0.19497241124386178 1.0 0.5 0.433757460808162
864.0 0.22833492954177637 1.0 0.5 0.5184093393054244
865.0 0.8948424632463157 1.0 0.5 4.504591406380232
866.0 0.8605530887700942 1.0 0.5 3.9401426296279958
867.0 0.15650870586231802 1.0 0.5 0.34041139633305906
868.0 0.45930982890306726 1.0 0.5 1.2298177217350685
869.0 0.3246506528569505 1.0 0.5 0.7850503413401291
870.0 0.9510363593524436 1.0 0.5 6.033354567822288
871.0 0.5038715294705464 1.0 0.5 1.4018407452622141
872.0 5.1203794293428584e-2 1.0 0.5 0.10512249958235921
873.0 0.5544890265721415 1.0 0.5 1.617066801324528
874.0 0.2614676505710716 1.0 0.5 0.6061807474664205
875.0 5.243774821209923e-2 1.0 0.5 0.10772528617673659
876.0 0.7971971719215974 1.0 0.5 3.191042124405132
877.0 0.7919800318693259 1.0 0.5 3.140242406520687
878.0 0.5219283825848018 1.0 0.5 1.4759894609704223
879.0 0.4275949818719734 1.0 0.5 1.1158169290356357
880.0 0.6781991679783914 1.0 0.5 2.267644917806484
881.0 0.8932373960711312 1.0 0.5 4.4742951285035835
882.0 0.5478472624532599 1.0 0.5 1.5874704826077597
883.0 0.5685711063530478 1.0 0.5 1.6813051416100346
884.0 0.9721023498460244 1.0 0.5 7.158425635147378
885.0 0.21573425270663737 1.0 0.5 0.486014705364895
886.0 0.35259191127848954 1.0 0.5 0.8695568868089019
887.0 0.3472690789117947 1.0 0.5 0.853180600685918
888.0 0.5447448280041739 1.0 0.5 1.573794399314694
889.0 0.6727997991506037 1.0 0.5 2.2343661208216705
890.0 0.8696740488652007 1.0 0.5 4.0754333003570125
891.0 0.8734188023436674 1.0 0.5 4.133742596048804
892.0 0.29463161413393557 1.0 0.5 0.6980701589988371
893.0 3.283064353893961e-2 1.0 0.5 6.676332583206068e-2
894.0 0.23328215590600432 1.0 0.5 0.5312728295896356
895.0 0.40670843024467607 1.0 0.5 1.044138629788592
896.0 0.8227097978732368 1.0 0.5 3.45993465796266
897.0 0.7693837137837822 1.0 0.5 2.9340000964909345
898.0 0.5297116607776882 1.0 0.5 1.5088185693552791
899.0 0.7754688592512937 1.0 0.5 2.98748173968772
900.0 0.3248143864258809 1.0 0.5 0.7855352856755076
901.0 0.9401865839181958 1.0 0.5 5.633050587988034
902.0 0.34780122634541877 1.0 0.5 0.8548117918995641
903.0 0.7284097775344618 1.0 0.5 2.6069217674085974
904.0 0.9414922145837621 1.0 0.5 5.677190899121933
905.0 0.9905747699450492 1.0 0.5 9.328730273865226
906.0 0.6248601140341811 1.0 0.5 1.9609125866553052
907.0 2.9604572975377663e-2 1.0 0.5 6.010326765544391e-2
908.0 5.571585670694823e-3 1.0 0.5 1.1174329696467535e-2
909.0 0.6109088431526207 1.0 0.5 1.8878832528951692
910.0 0.4546914044998336 1.0 0.5 1.2128068285824642
911.0 6.989233588498944e-2 1.0 0.5 0.1449098633396298
912.0 7.423451728270214e-2 1.0 0.5 0.1542686696318581
913.0 0.5259803352971397 1.0 0.5 1.4930129428654308
914.0 0.658351708925572 1.0 0.5 2.1479469194904803
915.0 0.7900569250260353 1.0 0.5 3.121837713127503
916.0 0.23734310603381692 1.0 0.5 0.5418940581763712
917.0 0.5669448736548646 1.0 0.5 1.6737804930156697
918.0 0.32179695871984115 1.0 0.5 0.7766171299190336
919.0 0.10866609186678144 1.0 0.5 0.23007233022421117
920.0 0.45705634966886644 1.0 0.5 1.2214994782912616
921.0 0.9167978760940737 1.0 0.5 4.972964807530681
922.0 0.3082714338000597 1.0 0.5 0.7371232913772323
923.0 0.47735097863544884 1.0 0.5 1.2976902549082674
924.0 0.4404786851833078 1.0 0.5 1.161347311537362
925.0 0.7939848260637378 1.0 0.5 3.1596109060410877
926.0 0.2412573034838612 1.0 0.5 0.5521851246673014
927.0 0.3000287671367394 1.0 0.5 0.7134320813856403
928.0 0.6396708208326259 1.0 0.5 2.0414745575053637
929.0 0.7579547542491935 1.0 0.5 2.83726120877795
930.0 0.3396814387067095 1.0 0.5 0.8300657835650016
931.0 0.2892910263130618 1.0 0.5 0.6829845053640449
932.0 0.9011216837211008 1.0 0.5 4.6277306266829745
933.0 0.8210499505161656 1.0 0.5 3.441297130493794
934.0 0.20855830013501853 1.0 0.5 0.4677981203133048
935.0 0.20067661109578638 1.0 0.5 0.4479793460879907
936.0 0.2783975695108384 1.0 0.5 0.6525618840897621
937.0 8.228356433882655e-2 1.0 0.5 0.171733659388771
938.0 0.6509731323562694 1.0 0.5 2.105212750180706
939.0 0.22847862352050963 1.0 0.5 0.5187817997542151
940.0 0.8395983631124934 1.0 0.5 3.6601487571349267
941.0 0.9743748330931115 1.0 0.5 7.328360656210449
942.0 0.9784624250877514 1.0 0.5 7.675912397820349
943.0 0.30092332380443143 1.0 0.5 0.7159896972722992
944.0 0.9500911854862217 1.0 0.5 5.995115296523221
945.0 8.677317380760863e-2 1.0 0.5 0.1815419774519955
946.0 0.7801060191136249 1.0 0.5 3.0292195076905384
947.0 0.8407117298539127 1.0 0.5 3.674079397023548
948.0 2.5783170671583644e-2 1.0 0.5 5.2242765469739556e-2
949.0 0.6060746119884648 1.0 0.5 1.8631875162923288
950.0 0.5958910047385527 1.0 0.5 1.8121412943134505
951.0 0.1746502894487323 1.0 0.5 0.3838961817736315
952.0 0.5840255212924214 1.0 0.5 1.7542627397268897
953.0 0.39662332502701947 1.0 0.5 1.010427217997472
954.0 0.8294609650651269 1.0 0.5 3.5375821291253438
955.0 0.6431589573123884 1.0 0.5 2.060929709875304
956.0 0.985945005032187 1.0 0.5 8.52955486531813
957.0 0.6701686585706427 1.0 0.5 2.218347683497157
958.0 0.9097930895031728 1.0 0.5 4.8112984836026484
959.0 0.9461308232792471 1.0 0.5 5.842393650220309
960.0 5.2337673573452204e-2 1.0 0.5 0.10751407186495446
961.0 0.8460764659780871 1.0 0.5 3.7425986644134888
962.0 0.10514312394105463 1.0 0.5 0.22218297702597922
963.0 0.6975701033741791 1.0 0.5 2.3918115501203125
964.0 0.9576315406611462 1.0 0.5 6.322702154160914
965.0 0.5756726043081537 1.0 0.5 1.714499924122977
966.0 0.14180795869433915 1.0 0.5 0.3058547603470779
967.0 0.476602852426136 1.0 0.5 1.2948294774050015
968.0 0.5735933728030692 1.0 0.5 1.7047237280891907
969.0 0.21074148987963792 1.0 0.5 0.47332273812264397
970.0 0.4040283383810781 1.0 0.5 1.0351243213329395
971.0 0.44809616679520103 1.0 0.5 1.188762926181943
972.0 0.49753260138877997 1.0 0.5 1.376449039078463
973.0 0.3981895324367999 1.0 0.5 1.0156254423601343
974.0 0.4631341447354761 1.0 0.5 1.2440140393123216
975.0 0.7621220718869883 1.0 0.5 2.8719952879613677
976.0 0.35491286990322435 1.0 0.5 0.8767397717764418
977.0 0.5624416059435056 1.0 0.5 1.6530902199238997
978.0 0.9048958001682184 1.0 0.5 4.705564296273839
979.0 0.5871353426885598 1.0 0.5 1.769270891992473
980.0 0.9552974642377905 1.0 0.5 6.215450101021099
981.0 0.11683294268351829 1.0 0.5 0.24848180677799192
982.0 0.804763553103361 1.0 0.5 3.2670878135466657
983.0 0.9017746463190758 1.0 0.5 4.640981825644075
984.0 0.3546593618234335 1.0 0.5 0.8759539607786164
985.0 0.8175329055993971 1.0 0.5 3.4023708537413193
986.0 0.9271651336840998 1.0 0.5 5.239121011041082
987.0 0.43755514801054285 1.0 0.5 1.150924381235035
988.0 0.12335439229044076 1.0 0.5 0.2633049287820745
989.0 0.3823717678509384 1.0 0.5 0.9637371372795477
990.0 0.7134192888551714 1.0 0.5 2.499470136417535
991.0 0.5559806916407091 1.0 0.5 1.6237744603995141
992.0 0.7947950806945909 1.0 0.5 3.167492385499269
993.0 0.8593443260366468 1.0 0.5 3.9228808076956767
994.0 0.9695468897099642 1.0 0.5 6.983134291741286
995.0 9.645307355937993e-2 1.0 0.5 0.20285446358422873
996.0 0.5759218175673997 1.0 0.5 1.7156748964373492
997.0 0.8948271404741518 1.0 0.5 4.504300002523024
998.0 0.8288317043606008 1.0 0.5 3.5302160428926017
999.0 0.7727026977235016 1.0 0.5 2.962992833506503
dfExpRand.describe().show() // look sensible
+-------+-----------------+--------------------+----+----+--------------------+
|summary|               Id|                rand| one|rate|         expo_sample|
+-------+-----------------+--------------------+----+----+--------------------+
|  count|             1000|                1000|1000|1000|                1000|
|   mean|            499.5|  0.5060789944940257| 1.0| 0.5|   2.024647367046763|
| stddev|288.8194360957494| 0.28795893414434537| 0.0| 0.0|  1.9649069025265538|
|    min|                0|6.282087728304298E-4| 1.0| 0.5|0.001256812357281...|
|    max|              999|  0.9981606891187609| 1.0| 0.5|  12.596728597154938|
+-------+-----------------+--------------------+----+----+--------------------+
val expoSamplesDF = spark.range(1000000000).toDF("Id") // just make a DF of 100 row indices
               .select($"Id", rand(seed=1234567) as "rand") // add a column of random numbers in (0,1)
               .withColumn("one",lit(1.0))
               .withColumn("rate",lit(0.5))
               .withColumn("expo_sample", -($"one" / $"rate") * log($"one" - $"rand"))
expoSamplesDF: org.apache.spark.sql.DataFrame = [Id: bigint, rand: double ... 3 more fields]
expoSamplesDF.describe().show()
+-------+--------------------+--------------------+----------+----------+--------------------+
|summary|                  Id|                rand|       one|      rate|         expo_sample|
+-------+--------------------+--------------------+----------+----------+--------------------+
|  count|          1000000000|          1000000000|1000000000|1000000000|          1000000000|
|   mean|4.9999999907595944E8| 0.49999521358240573|       1.0|       0.5|  1.9999814119383708|
| stddev|2.8867513473915565E8|  0.2886816216562552|       0.0|       0.0|  2.0000011916404206|
|    min|                   0|1.584746778249268...|       1.0|       0.5|3.169493556749679...|
|    max|           999999999|  0.9999999996809935|       1.0|       0.5|  43.731619350261035|
+-------+--------------------+--------------------+----------+----------+--------------------+

Using sql.functions and sql.expr for expressions, one can write a much simpler syntax to get Exponetially distributed samples.

See: - spark/sql/expressions/ docs - https://sparkbyexamples.com/spark/spark-sql-functions/

import org.apache.spark.sql.functions._
import org.apache.spark.sql.functions.expr

val expoSamplesDFAsSQLExp = spark.range(1000000000).toDF("Id") // just make a DF of 100 row indices
               .select($"Id", rand(seed=1234567) as "random") // add a column of random numbers in (0,1)
               .withColumn("expo_sample", expr("-(1.0 / 0.5) * log(1.0 - random)"))
import org.apache.spark.sql.functions._
import org.apache.spark.sql.functions.expr
expoSamplesDFAsSQLExp: org.apache.spark.sql.DataFrame = [Id: bigint, random: double ... 1 more field]
expoSamplesDFAsSQLExp.describe().show()
+-------+--------------------+--------------------+--------------------+
|summary|                  Id|              random|         expo_sample|
+-------+--------------------+--------------------+--------------------+
|  count|          1000000000|          1000000000|          1000000000|
|   mean|4.9999999907595944E8| 0.49999521358240573|  1.9999814119383708|
| stddev|2.8867513473915565E8|  0.2886816216562552|  2.0000011916404206|
|    min|                   0|1.584746778249268...|3.169493556749679...|
|    max|           999999999|  0.9999999996809935|  43.731619350261035|
+-------+--------------------+--------------------+--------------------+

Approximating Pi with Monte Carlo simulations

Uisng RDDs directly, let's estimate Pi.

//Calculate pi with Monte Carlo estimation
import scala.math.random

//make a very large unique set of 1 -> n 
val partitions = 2 
val n = math.min(100000L * partitions, Int.MaxValue).toInt 
val xs = 1 until n 

//split up n into the number of partitions we can use 
val rdd = sc.parallelize(xs, partitions).setName("'N values rdd'")

//generate a random set of points within a 2x2 square
val sample = rdd.map { i =>
  val x = random * 2 - 1
  val y = random * 2 - 1
  (x, y)
}.setName("'Random points rdd'")

//points w/in the square also w/in the center circle of r=1
val inside = sample.filter { case (x, y) => (x * x + y * y < 1) }.setName("'Random points inside circle'")
val count = inside.count()
 
//Area(circle)/Area(square) = inside/n => pi=4*inside/n                        
println("Pi is roughly " + 4.0 * count / n)
Pi is roughly 3.1387
import scala.math.random
partitions: Int = 2
n: Int = 200000
xs: scala.collection.immutable.Range = Range 1 until 200000
rdd: org.apache.spark.rdd.RDD[Int] = 'N values rdd' ParallelCollectionRDD[192] at parallelize at command-2971213210276568:10
sample: org.apache.spark.rdd.RDD[(Double, Double)] = 'Random points rdd' MapPartitionsRDD[193] at map at command-2971213210276568:13
inside: org.apache.spark.rdd.RDD[(Double, Double)] = 'Random points inside circle' MapPartitionsRDD[194] at filter at command-2971213210276568:20
count: Long = 156935

Doing it in PySpark is just as easy. This may be needed if there are pyhton libraries you want to take advantage of in Spark.

# # Estimating $\pi$
#
# This PySpark example shows you how to estimate $\pi$ in parallel
# using Monte Carlo integration.

from __future__ import print_function
import sys
from random import random
from operator import add

partitions = 2
n = 100000 * partitions

def f(_):
    x = random() * 2 - 1
    y = random() * 2 - 1
    return 1 if x ** 2 + y ** 2 < 1 else 0

# To access the associated SparkContext
count = spark.sparkContext.parallelize(range(1, n + 1), partitions).map(f).reduce(add)
print("Pi is roughly %f" % (4.0 * count / n))

The following is from this google turotial.

Programming a Monte Carlo simulation in Scala

Monte Carlo, of course, is famous as a gambling destination. In this section, you use Scala to create a simulation that models the mathematical advantage that a casino enjoys in a game of chance. The "house edge" at a real casino varies widely from game to game; it can be over 20% in keno, for example. This tutorial creates a simple game where the house has only a one-percent advantage. Here's how the game works:

  1. The player places a bet, consisting of a number of chips from a bankroll fund.
  • The player rolls a 100-sided die (how cool would that be?).
  • If the result of the roll is a number from 1 to 49, the player wins.
  • For results 50 to 100, the player loses the bet.

You can see that this game creates a one-percent disadvantage for the player: in 51 of the 100 possible outcomes for each roll, the player loses.

Follow these steps to create and run the game:

val STARTING_FUND = 10
val STAKE = 1   // the amount of the bet
val NUMBER_OF_GAMES = 25

def rollDie: Int = {
    val r = scala.util.Random
    r.nextInt(99) + 1
}

def playGame(stake: Int): (Int) = {
    val faceValue = rollDie
    if (faceValue < 50)
        (2*stake)
    else
        (0)
}

// Function to play the game multiple times
// Returns the final fund amount
def playSession(
   startingFund: Int = STARTING_FUND,
   stake: Int = STAKE,
   numberOfGames: Int = NUMBER_OF_GAMES):
   (Int) = {

    // Initialize values
    var (currentFund, currentStake, currentGame) = (startingFund, 0, 1)

    // Keep playing until number of games is reached or funds run out
    while (currentGame <= numberOfGames && currentFund > 0) {

        // Set the current bet and deduct it from the fund
        currentStake = math.min(stake, currentFund)
        currentFund -= currentStake

        // Play the game
        val (winnings) = playGame(currentStake)

        // Add any winnings
        currentFund += winnings

        // Increment the loop counter
        currentGame += 1
    }
    (currentFund)
}
STARTING_FUND: Int = 10
STAKE: Int = 1
NUMBER_OF_GAMES: Int = 25
rollDie: Int
playGame: (stake: Int)Int
playSession: (startingFund: Int, stake: Int, numberOfGames: Int)Int

Enter the following code to play the game 25 times, which is the default value for NUMBER_OF_GAMES.

playSession()
res31: Int = 5

Your bankroll started with a value of 10 units. Is it higher or lower, now?

Now simulate 10,000 players betting 100 chips per game. Play 10,000 games in a session. This Monte Carlo simulation calculates the probability of losing all your money before the end of the session. Enter the follow code:

(sc.parallelize(1 to 10000, 500)
  .map(i => playSession(100000, 100, 250000))
  .map(i => if (i == 0) 1 else 0)
  .reduce(_+_)/10000.0)
res32: Double = 0.9992

Note that the syntax .reduce(_+_) is shorthand in Scala for aggregating by using a summing function.

The preceding code performs the following steps:

  1. Creates an RDD with the results of playing the session.
  • Replaces bankrupt players' results with the number 1 and nonzero results with the number 0.
  • Sums the count of bankrupt players.
  • Divides the count by the number of players.

A typical result might be:

res32: Double = 0.9992

Which represents a near guarantee of losing all your money, even though the casino had only a one-percent advantage.

Project Ideas

Try to create a scalable simulation of interest to you.

Here are some mature projects:

  • https://github.com/zishanfu/GeoSparkSim
  • https://github.com/srbaird/mc-var-spark

See a more complete VaR modeling: - https://databricks.com/blog/2020/05/27/modernizing-risk-management-part-1-streaming-data-ingestion-rapid-model-development-and-monte-carlo-simulations-at-scale.html