-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
575 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# In this example we will show the difference between a 2-d Sobol sequence | ||
# and sampling uniformly at random in 2 dimensions. | ||
# The Sobol sequence has far lower discrepancy, i.e., the generated samples | ||
# are spread out better in the sampling space. | ||
# | ||
# This example requires matplotlib to generate figures. | ||
|
||
import matplotlib.pyplot as plt | ||
import optunity | ||
import random | ||
|
||
num_pts = 200 # the number of points to generate | ||
skip = 5000 # the number of initial points of the Sobol sequence to skip | ||
|
||
# generate Sobol sequence | ||
res = optunity.solvers.Sobol.i4_sobol_generate(2, num_pts, skip) | ||
x1_sobol, x2_sobol = zip(*res) | ||
|
||
# generate uniform points | ||
x1_random = [random.random() for _ in range(num_pts)] | ||
x2_random = [random.random() for _ in range(num_pts)] | ||
|
||
# plot results | ||
plt.figure(1) | ||
plt.plot(x1_sobol, x2_sobol, 'o') | ||
plt.title('Sobol sequence') | ||
plt.draw() | ||
|
||
plt.figure(2) | ||
plt.plot(x1_random, x2_random, 'ro') | ||
plt.title('Uniform random samples') | ||
plt.show() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.