"docs/vscode:/vscode.git/clone" did not exist on "eb9b72a3a30afb66ed0ef5def7e2df97c0ea3a6f"
Commit a2e45f23 authored by suiguoxin's avatar suiguoxin
Browse files

fix quniform issue ; change related doc

parent 88b75065
...@@ -45,7 +45,8 @@ All types of sampling strategies and their parameter are listed here: ...@@ -45,7 +45,8 @@ All types of sampling strategies and their parameter are listed here:
* When optimizing, this variable is constrained to a two-sided interval. * When optimizing, this variable is constrained to a two-sided interval.
* {"_type":"quniform","_value":[low, high, q]} * {"_type":"quniform","_value":[low, high, q]}
* Which means the variable value is a value like round(uniform(low, high) / q) * q * Which means the variable value is a value like randint(np.floor((high-low)/q)+1)*q + low. For example, for _value specified as [0, 10, 2.5], possible values are [0, 2.5, 5.0, 7.5, 10.0]; For _value specified as [2, 10, 5], possible values are [2, 7]. All possible values have the same possibility to be selected.
* Suitable for a discrete value with respect to which the objective is still somewhat "smooth", but which should be bounded both above and below. If you want to uniformly choose integer from a range [low, high], you can write `_value` like this: `[low, high, 1]`. * Suitable for a discrete value with respect to which the objective is still somewhat "smooth", but which should be bounded both above and below. If you want to uniformly choose integer from a range [low, high], you can write `_value` like this: `[low, high, 1]`.
* {"_type":"loguniform","_value":[low, high]} * {"_type":"loguniform","_value":[low, high]}
......
...@@ -57,7 +57,7 @@ def quniform(low, high, q, random_state): ...@@ -57,7 +57,7 @@ def quniform(low, high, q, random_state):
q: sample step q: sample step
random_state: an object of numpy.random.RandomState random_state: an object of numpy.random.RandomState
''' '''
return np.round(uniform(low, high, random_state) / q) * q return randint(np.floor((high-low)/q)+1, random_state) * q + low
def loguniform(low, high, random_state): def loguniform(low, high, random_state):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment