diff --git a/_posts/2021-06-30-Sampling-integration-volume-in-R.md b/_posts/2021-06-30-Sampling-integration-volume-in-R.md index 8eba136..e64de81 100644 --- a/_posts/2021-06-30-Sampling-integration-volume-in-R.md +++ b/_posts/2021-06-30-Sampling-integration-volume-in-R.md @@ -80,12 +80,45 @@ The output of the above script, shows that the performance of `volesti` is ~2500 times faster than `hitandrun`. +The following R script generates a random polytope for each dimension and samples 10000 points (walk length = 5) with both packages. + +```R +for (d in seq(from = 10, to = 100, by = 10)) { + + P = gen_cube(d, 'H') + tim = system.time({ sample_points(P, n = 10000, random_walk = list( + "walk" = "RDHR", "walk_length"=5)) }) + + constr <- list(constr = P$A, dir=rep('<=', 2*d), rhs=P$b) + tim = system.time({ hitandrun::hitandrun(constr, n.samples = 10000, thin=5) }) +} +``` +The following Table reports the run-times. + +| dimension | volesti time | hitandrun time | +| --------- | ------------ | -------------- | +| 10 | 0.017 | 0.102 | +| 20 | 0.024 | 0.157 | +| 30 | 0.031 | 0.593 | +| 40 | 0.043 | 1.471 | +| 50 | 0.055 | 3.311 | +| 60 | 0.069 | 6.460 | +| 70 | 0.089 | 11.481 | +| 80 | 0.108 | 19.056 | +| 90 | 0.132 | 33.651 | +| 100 | 0.156 | 50.482 | + +The following figure illustrates the asymptotic in the dimension difference in run-time between `volesti` and `hitandrun`. + + + ## Comparison with restrictedMVN and tmg In many Bayesian models the posterior distribution is a multivariate Gaussian -distribution restricted to a specific domain. +distribution restricted to a specific domain. For more details on Bayesian inference you can read the [Wikipedia page](https://en.wikipedia.org/wiki/Bayesian_statistics). + We illustrate the efficiency of `volesti` for the case of the truncation being the canonical simplex,