Skip to content

Commit 701027f

Browse files
BenHewinsBenHewins
authored andcommitted
Fixed formatting
1 parent 656f235 commit 701027f

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

src/UnitTests/DistributionTests/Continuous/TruncatedNormalTests.cs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public void ValidateMode(double mean, double stdDev, double lower, double upper)
108108
[TestCase(6.0, .69146246127401310363770461060833773988360217555457859)]
109109
[TestCase(10.0, 0.9937903346742238648330218954258077788721022530769078)]
110110
[TestCase(Double.PositiveInfinity, 1.0)]
111-
public void ValidateCumulativeNoBounds(double x, double p) {
111+
public void ValidateCumulativeNoBounds(double x, double p)
112+
{
112113
var truncatedNormal = new TruncatedNormal(5.0, 2.0);
113114
AssertHelpers.AlmostEqualRelative(p, truncatedNormal.CumulativeDistribution(x), 14);
114115
}
@@ -146,7 +147,8 @@ public void ValidateInverseCumulativeNoBounds(double x, double p)
146147
[TestCase(0.0, 10.0)]
147148
[TestCase(10.0, 100.0)]
148149
[TestCase(-5.0, Double.PositiveInfinity)]
149-
public void ValidateDensityNoBounds(double mean, double sdev) {
150+
public void ValidateDensityNoBounds(double mean, double sdev)
151+
{
150152
var n = new TruncatedNormal(mean, sdev);
151153
for (var i = 0; i < 11; i++) {
152154
var x = i - 5.0;
@@ -166,15 +168,20 @@ public void ValidateDensityNoBounds(double mean, double sdev) {
166168
[TestCase(0.0, 10.0, -10.0)]
167169
[TestCase(10.0, 100.0, 15.0)]
168170
[TestCase(-5.0, Double.PositiveInfinity, -5.0)]
169-
public void ValidateDensitySemiFinite(double mean, double sdev, double lowerBound) {
171+
public void ValidateDensitySemiFinite(double mean, double sdev, double lowerBound)
172+
{
170173
var truncatedNormal = new TruncatedNormal(mean, sdev, lowerBound);
171174
var normal = new Normal(mean, sdev);
172-
for (var i = 0; i < 11; i++) {
175+
for (var i = 0; i < 11; i++)
176+
{
173177
var x = i - 5.0;
174178
double density;
175-
if(x < lowerBound) {
179+
if(x < lowerBound)
180+
{
176181
density = 0d;
177-
} else {
182+
}
183+
else
184+
{
178185
var d = (mean - x) / sdev;
179186
var pdf = Math.Exp(-0.5 * d * d) / (sdev * Constants.Sqrt2Pi);
180187
density = pdf / (1.0 - normal.CumulativeDistribution(lowerBound));
@@ -193,15 +200,20 @@ public void ValidateDensitySemiFinite(double mean, double sdev, double lowerBoun
193200
[TestCase(0.0, 10.0, -10.0, 15.0)]
194201
[TestCase(10.0, 100.0, 15.0, 100.0)]
195202
[TestCase(-5.0, Double.PositiveInfinity, -5.0, 0.0)]
196-
public void ValidateDensityFinite(double mean, double sdev, double lowerBound, double upperBound) {
203+
public void ValidateDensityFinite(double mean, double sdev, double lowerBound, double upperBound)
204+
{
197205
var truncatedNormal = new TruncatedNormal(mean, sdev, lowerBound, upperBound);
198206
var normal = new Normal(mean, sdev);
199-
for (var i = 0; i < 11; i++) {
207+
for (var i = 0; i < 11; i++)
208+
{
200209
var x = i - 5.0;
201210
double density;
202-
if (x < lowerBound || upperBound < x) {
211+
if (x < lowerBound || upperBound < x)
212+
{
203213
density = 0d;
204-
} else {
214+
}
215+
else
216+
{
205217
var d = (mean - x) / sdev;
206218
var pdf = Math.Exp(-0.5 * d * d) / (sdev * Constants.Sqrt2Pi);
207219
density = pdf / (normal.CumulativeDistribution(upperBound) - normal.CumulativeDistribution(lowerBound));
@@ -222,9 +234,11 @@ public void ValidateDensityFinite(double mean, double sdev, double lowerBound, d
222234
[TestCase(0.0, 10.0)]
223235
[TestCase(10.0, 100.0)]
224236
[TestCase(-5.0, Double.PositiveInfinity)]
225-
public void ValidateDensityLnNoBounds(double mean, double sdev) {
237+
public void ValidateDensityLnNoBounds(double mean, double sdev)
238+
{
226239
var n = new TruncatedNormal(mean, sdev);
227-
for (var i = 0; i < 11; i++) {
240+
for (var i = 0; i < 11; i++)
241+
{
228242
var x = i - 5.0;
229243
var d = (mean - x) / sdev;
230244
var pdfln = (-0.5 * (d * d)) - Math.Log(sdev) - Constants.LogSqrt2Pi;
@@ -244,7 +258,8 @@ public void CanSample()
244258
/// Can sample sequence.
245259
/// </summary>
246260
[Test]
247-
public void CanSampleSequence() {
261+
public void CanSampleSequence()
262+
{
248263
var truncatedNormal = new TruncatedNormal(5.0, 2.0, -10, 10.0);
249264
var ied = truncatedNormal.Samples();
250265
GC.KeepAlive(ied.Take(5).ToArray());

0 commit comments

Comments
 (0)