Definition at line 73 of file samplers.py.
◆ __init__()
def python.samplers.DisjointUniformSampler.__init__ |
( |
|
self, |
|
|
|
ranges |
|
) |
| |
The ranges variable can either be a list of increasing numbers or a
list of pairs of numbers.
The former case will be treated as
defining alternating on/off ranges for sampling, starting with an active
one (i.e. it's a list of bin edges). The latter way specifically lists
the 'on' regions only, with their start and end values in the pairs.
The behaviour is undefined if the numbers are not ordered or overlap --
i.e. it might work but hasn't been designed that way and might change in
future. Don't rely on this behaviour!
Definition at line 76 of file samplers.py.
78 The ranges variable can either be a list of increasing numbers or a
79 list of pairs of numbers.
81 The former case will be treated as
82 defining alternating on/off ranges for sampling, starting with an active
83 one (i.e. it's a list of bin edges). The latter way specifically lists
84 the 'on' regions only, with their start and end values in the pairs.
86 The behaviour is undefined if the numbers are not ordered or overlap --
87 i.e. it might work but hasn't been designed that way and might change in
88 future. Don't rely on this behaviour!
91 raise Exception(
"You must supply at least one non-null sampling range")
92 if hasattr(ranges[0],
"__len__"):
93 assert all(len(x) == 2
for x
in ranges)
96 assert len(ranges) > 1
97 lows = [x
for x
in ranges[:-1]]
98 highs = [x
for x
in ranges[1:]]
100 for i, pair
in enumerate(zip(lows, highs)):
102 myranges.append(pair)
103 assert len(myranges) == len(ranges) // 2
104 self.ranges = myranges
◆ __call__()
def python.samplers.Sampler.__call__ |
( |
|
self | ) |
|
|
inherited |
This is the call method that will actually be used (so that normal
functions can also be passed in as samplers).
Definition at line 17 of file samplers.py.
18 """This is the call method that will actually be used (so that normal
19 functions can also be passed in as samplers)."""
◆ _getRanges()
def python.samplers.DisjointUniformSampler._getRanges |
( |
|
self | ) |
|
|
private |
◆ _map_unit_to_val()
def python.samplers.DisjointUniformSampler._map_unit_to_val |
( |
|
self, |
|
|
|
x |
|
) |
| |
|
private |
Definition at line 126 of file samplers.py.
126 def _map_unit_to_val(self, x):
127 assert(x >= 0
and x <= 1)
130 for i
in range(len(self._divisions) - 1):
131 if x >= self._divisions[i]
and x < self._divisions[i+1]:
133 rem = x - self._divisions[i]
136 raise ValueError(
"No matching division found in unit interval! How?")
137 val = self.ranges[idx][0] + self._totalwidth * rem
◆ _setRanges()
def python.samplers.DisjointUniformSampler._setRanges |
( |
|
self, |
|
|
|
ranges |
|
) |
| |
|
private |
Definition at line 109 of file samplers.py.
109 def _setRanges(self, ranges):
111 self._ranges = ranges
112 self._totalwidth =
sum(r[1] - r[0]
for r
in ranges)
115 self._divisions = [0.0]
118 runningwidth +=
float(r[1] - r[0])
119 self._divisions.
append(runningwidth)
120 self._totalwidth = runningwidth
121 for i
in range(len(self._divisions)):
122 self._divisions[i] =
float(self._divisions[i]) /
float(self._totalwidth)
◆ shoot()
def python.samplers.DisjointUniformSampler.shoot |
( |
|
self | ) |
|
◆ _divisions
python.samplers.DisjointUniformSampler._divisions |
|
private |
◆ _ranges
python.samplers.DisjointUniformSampler._ranges |
|
private |
◆ _totalwidth
python.samplers.DisjointUniformSampler._totalwidth |
|
private |
◆ ranges
The documentation for this class was generated from the following file: