Skip to content

Commit 6fafde8

Browse files
author
Sofiane HADDAD
committed
Perform VisualTest::DrawEmpiricalCDF
xMin & xMax are now optional Also, add a missing dimension check
1 parent 01291b1 commit 6fafde8

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

lib/src/Uncertainty/StatTests/VisualTest.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ VisualTest::VisualTest()
4040
{
4141
}
4242

43+
/* Draw the empirical CDF of the Sample when its dimension is 1 */
44+
Graph VisualTest::DrawEmpiricalCDF(const Sample & sample)
45+
{
46+
if (sample.getDimension() != 1)
47+
throw InvalidDimensionException(HERE) << "In VisualTest::DrawEmpiricalCDF: sample should be of dimension 1, here dimension=" << sample.getDimension();
48+
return UserDefined(sample).drawCDF();
49+
}
50+
4351
/* Draw the empirical CDF of the Sample when its dimension is 1 */
4452
Graph VisualTest::DrawEmpiricalCDF(const Sample & sample,
4553
const Scalar xMin,
4654
const Scalar xMax)
4755
{
56+
if (sample.getDimension() != 1)
57+
throw InvalidDimensionException(HERE) << "In VisualTest::DrawEmpiricalCDF: sample should be of dimension 1, here dimension=" << sample.getDimension();
4858
return UserDefined(sample).drawCDF(xMin, xMax);
4959
}
5060

lib/src/Uncertainty/StatTests/openturns/VisualTest.hxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public:
4040

4141

4242
/** Draw the empirical CDF of the Sample when its dimension is 1 */
43+
static Graph DrawEmpiricalCDF(const Sample & sample);
44+
4345
static Graph DrawEmpiricalCDF(const Sample & sample,
4446
const Scalar xMin,
4547
const Scalar xMax);

python/src/VisualTest_doc.i.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ Draw an histogram:
268268
"Draw an empirical CDF.
269269

270270
Available usages:
271+
VisualTest.DrawEmpiricalCDF(*sample*)
271272
VisualTest.DrawEmpiricalCDF(*sample, Xmin, Xmax*)
272273

273274
Parameters
@@ -296,12 +297,10 @@ Generate a random sample from a Normal distribution:
296297

297298
>>> ot.RandomGenerator.SetSeed(0)
298299
>>> sample = ot.Normal(1).getSample(100)
299-
>>> Xmin = sample.getMin()[0]
300-
>>> Xmax = sample.getMax()[0]
301300

302301
Draw an empirical CDF:
303302

304-
>>> empiricalCDF = ot.VisualTest.DrawEmpiricalCDF(sample, Xmin - 1.0, Xmax + 1.0)
303+
>>> empiricalCDF = ot.VisualTest.DrawEmpiricalCDF(sample)
305304
>>> View(empiricalCDF).show()"
306305

307306
// ---------------------------------------------------------------------

0 commit comments

Comments
 (0)