stats: Fix off-by-one error in distributions.
bkt size isn't evenly divisible by max-min and it would round down, it's possible to sample a distribution and have no place to put the sample. When this case occured the simulator would assert.
This commit is contained in:
parent
fa01fbddeb
commit
7793773809
1 changed files with 2 additions and 2 deletions
|
@ -2287,7 +2287,7 @@ class Distribution : public DistBase<Distribution, DistStor>
|
||||||
params->min = min;
|
params->min = min;
|
||||||
params->max = max;
|
params->max = max;
|
||||||
params->bucket_size = bkt;
|
params->bucket_size = bkt;
|
||||||
params->buckets = (size_type)rint((max - min + 1.0) / bkt );
|
params->buckets = (size_type)ceil((max - min + 1.0) / bkt);
|
||||||
this->setParams(params);
|
this->setParams(params);
|
||||||
this->doInit();
|
this->doInit();
|
||||||
return this->self();
|
return this->self();
|
||||||
|
@ -2352,7 +2352,7 @@ class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>
|
||||||
params->min = min;
|
params->min = min;
|
||||||
params->max = max;
|
params->max = max;
|
||||||
params->bucket_size = bkt;
|
params->bucket_size = bkt;
|
||||||
params->buckets = (size_type)rint((max - min + 1.0) / bkt);
|
params->buckets = (size_type)ceil((max - min + 1.0) / bkt);
|
||||||
this->setParams(params);
|
this->setParams(params);
|
||||||
this->doInit(size);
|
this->doInit(size);
|
||||||
return this->self();
|
return this->self();
|
||||||
|
|
Loading…
Reference in a new issue