未验证 提交 717fba81 编写于 作者: X Xin Pan 提交者: GitHub

Merge pull request #13788 from wanghaoshuang/cherry-pick-fix-normal

Fix truncated normal.
...@@ -148,7 +148,7 @@ struct TruncatedNormal { ...@@ -148,7 +148,7 @@ struct TruncatedNormal {
T operator()(T value) const { T operator()(T value) const {
auto p = a_normal_cdf + (b_normal_cdf - a_normal_cdf) * value; auto p = a_normal_cdf + (b_normal_cdf - a_normal_cdf) * value;
return (std::sqrt(2.0) * Erfinv(2 * p - 1) + mean) * std; return std::sqrt(2.0) * Erfinv(2 * p - 1) * std + mean;
} }
}; };
......
...@@ -42,7 +42,7 @@ struct TruncatedNormal { ...@@ -42,7 +42,7 @@ struct TruncatedNormal {
rng.discard(n); rng.discard(n);
T value = dist(rng); T value = dist(rng);
auto p = a_normal_cdf + (b_normal_cdf - a_normal_cdf) * value; auto p = a_normal_cdf + (b_normal_cdf - a_normal_cdf) * value;
return (std::sqrt(2.0) * erfinvf(2 * p - 1) + mean) * std; return std::sqrt(2.0) * erfinvf(2 * p - 1) * std + mean;
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册