1%feature("docstring") OT::VisualTest::DrawHenryLine
2"Draw an Henry plot.
3
4Refer to :ref:`graphical_fitting_test`.
5
6Parameters
7----------
8sample : 2-d sequence of float
9    Tested (univariate) sample.
10normal_distribution : :class:`~openturns.Normal`, optional
11    Tested (univariate) normal distribution.
12
13    If not given, this will build a :class:`~openturns.Normal` distribution
14    from the given sample using the :class:`~openturns.NormalFactory`.
15
16Returns
17-------
18graph : :class:`~openturns.Graph`
19    The graph object
20
21Notes
22-----
23The Henry plot is a visual fitting test for the normal distribution. It
24opposes the sample quantiles to those of the standard normal distribution
25(the one with zero mean and unit variance) by plotting the following points
26could:
27
28.. math::
29
30    \left(x^{(i)},
31          \Phi^{-1}\left(\widehat{F}\left(x^{(i)}\right)\right)
32    \right), \quad i = 1, \ldots, m
33
34where :math:`\widehat{F}` denotes the empirical CDF of the sample and
35:math:`\Phi^{-1}` denotes the quantile function of the standard normal
36distribution.
37
38If the given sample fits to the tested normal distribution (with mean
39:math:`\mu` and standard deviation :math:`\sigma`), then the points should be
40close to be aligned (up to the uncertainty associated with the estimation
41of the empirical probabilities) on the **Henry line** whose equation reads:
42
43.. math::
44
45    y = \frac{x - \mu}{\sigma}, \quad x \in \Rset
46
47The Henry plot is a special case of the more general QQ-plot.
48
49See Also
50--------
51VisualTest_DrawQQplot, FittingTest_Kolmogorov
52
53Examples
54--------
55>>> import openturns as ot
56>>> from openturns.viewer import View
57
58Generate a random sample from a Normal distribution:
59
60>>> ot.RandomGenerator.SetSeed(0)
61>>> distribution = ot.Normal(2.0, 0.5)
62>>> sample = distribution.getSample(30)
63
64Draw an Henry plot against a given (wrong) Normal distribution:
65
66>>> henry_graph = ot.VisualTest.DrawHenryLine(sample, distribution)
67>>> henry_graph.setTitle('Henry plot against given %s' % ot.Normal(3.0, 1.0))
68>>> View(henry_graph).show()
69
70Draw an Henry plot against an inferred Normal distribution:
71
72>>> henry_graph = ot.VisualTest.DrawHenryLine(sample)
73>>> henry_graph.setTitle('Henry plot against inferred Normal distribution')
74>>> View(henry_graph).show()"
75
76// ---------------------------------------------------------------------
77
78%feature("docstring") OT::VisualTest::DrawQQplot
79"Draw a QQ-plot.
80
81Refer to :ref:`qqplot_graph`.
82
83Available usages:
84    VisualTest.DrawQQplot(*sample1, sample2, n_points*)
85
86    VisualTest.DrawQQplot(*sample1, distribution*);
87
88Parameters
89----------
90sample1, sample2 : 2-d sequences of float
91    Tested samples.
92ditribution : :class:`~openturns.Distribution`
93    Tested model.
94n_points : int, optional
95    The number of points that is used for interpolating the empirical CDF of
96    the two samples (with possibly different sizes).
97
98    It will default to *DistributionImplementation-DefaultPointNumber* from
99    the :class:`~openturns.ResourceMap`.
100
101Returns
102-------
103graph : :class:`~openturns.Graph`
104    The graph object
105
106Notes
107-----
108The QQ-plot is a visual fitting test for univariate distributions. It
109opposes the sample quantiles to those of the tested quantity (either a
110distribution or another sample) by plotting the following points cloud:
111
112.. math::
113
114    \left(x^{(i)},
115          \theta\left(\widehat{F}\left(x^{(i)}\right)\right)
116    \right), \quad i = 1, \ldots, m
117
118where :math:`\widehat{F}` denotes the empirical CDF of the (first) tested
119sample and :math:`\theta` denotes either the quantile function of the tested
120distribution or the empirical quantile function of the second tested sample.
121
122If the given sample fits to the tested distribution or sample, then the points
123should be close to be aligned (up to the uncertainty associated with the
124estimation of the empirical probabilities) with the **first bissector**  whose
125equation reads:
126
127.. math::
128
129    y = x, \quad x \in \Rset
130
131Examples
132--------
133>>> import openturns as ot
134>>> from openturns.viewer import View
135
136Generate a random sample from a Normal distribution:
137
138>>> ot.RandomGenerator.SetSeed(0)
139>>> distribution = ot.WeibullMin(2.0, 0.5)
140>>> sample = distribution.getSample(30)
141>>> sample.setDescription(['Sample'])
142
143Draw a QQ-plot against a given (inferred) distribution:
144
145>>> tested_distribution = ot.WeibullMinFactory().build(sample)
146>>> QQ_plot = ot.VisualTest.DrawQQplot(sample, tested_distribution)
147>>> View(QQ_plot).show()
148
149Draw a two-sample QQ-plot:
150
151>>> another_sample = distribution.getSample(50)
152>>> another_sample.setDescription(['Another sample'])
153>>> QQ_plot = ot.VisualTest.DrawQQplot(sample, another_sample)
154>>> View(QQ_plot).show()"
155
156// ---------------------------------------------------------------------
157
158%feature("docstring") OT::VisualTest::DrawCDFplot
159"Draw a CDF-plot.
160
161Refer to :ref:`qqplot_graph`.
162
163Available usages:
164    VisualTest.DrawCDFplot(*sample1, sample2*)
165
166    VisualTest.DrawCDFplot(*sample1, distribution*);
167
168Parameters
169----------
170sample1, sample2 : 2-d sequences of float
171    Tested samples.
172ditribution : :class:`~openturns.Distribution`
173    Tested model.
174
175Returns
176-------
177graph : class:`~openturns.Graph`
178    The graph object
179
180Notes
181-----
182The CDF-plot is a visual fitting test for univariate distributions. It
183opposes the normalized sample ranks to those of the tested quantity (either a
184distribution or another sample) by plotting the following points cloud:
185
186.. math::
187
188    \left(\dfrac{i+1/2}{m},
189          F(x^{(i)})
190    \right), \quad i = 1, \ldots, m
191
192where :math:`F` denotes either the CDF function of the tested
193distribution or the empirical CDF of the second tested sample.
194
195If the given sample fits to the tested distribution or sample, then the points
196should be close to be aligned (up to the uncertainty associated with the
197estimation of the empirical probabilities) with the **first bissector**  whose
198equation reads:
199
200.. math::
201
202    y = x, \quad x \in [0,1]
203
204Examples
205--------
206>>> import openturns as ot
207>>> from openturns.viewer import View
208
209Generate a random sample from a Normal distribution:
210
211>>> ot.RandomGenerator.SetSeed(0)
212>>> distribution = ot.WeibullMin(2.0, 0.5)
213>>> sample = distribution.getSample(30)
214>>> sample.setDescription(['Sample'])
215
216Draw a CDF-plot against a given (inferred) distribution:
217
218>>> tested_distribution = ot.WeibullMinFactory().build(sample)
219>>> CDF_plot = ot.VisualTest.DrawCDFplot(sample, tested_distribution)
220>>> View(CDF_plot).show()
221
222Draw a two-sample CDF-plot:
223
224>>> another_sample = distribution.getSample(50)
225>>> another_sample.setDescription(['Another sample'])
226>>> CDF_plot = ot.VisualTest.DrawCDFplot(sample, another_sample)
227>>> View(CDF_plot).show()"
228
229// ---------------------------------------------------------------------
230
231%feature("docstring") OT::VisualTest::DrawParallelCoordinates
232"Draw a parallel coordinates plot.
233
234Parameters
235----------
236inputSample : 2-d sequence of float of dimension :math:`n`
237    Input sample :math:`\vect{X}`.
238outputSample : 2-d sequence of float of dimension :math:`1`
239    Output sample :math:`Y`.
240Ymin, Ymax : float such that *Ymax > Ymin*
241    Values to select lines which will colore in *color*. Must be in
242    :math:`[0,1]` if *quantileScale=True*.
243color : str
244    Color of the specified curves.
245quantileScale : bool
246    Flag indicating the scale of the *Ymin* and *Ymax*. If
247    *quantileScale=True*, they are expressed in the rank based scale;
248    otherwise, they are expressed in the :math:`Y`-values scale.
249
250Returns
251-------
252graph : :class:`~openturns.Graph`
253    The graph object
254
255Notes
256-----
257Let's suppose a model :math:`f: \Rset^n \mapsto \Rset`, where
258:math:`f(\vect{X})=Y`.
259The Cobweb graph enables to visualize all the combinations of the input
260variables which lead to a specific range of the output variable.
261
262Each column represents one component :math:`X_i` of the input vector
263:math:`\vect{X}`. The last column represents the scalar output variable
264:math:`Y`.
265
266For each point :math:`\vect{X}^j` of *inputSample*, each component :math:`X_i^j`
267is noted on its respective axe and the last mark is the one which corresponds
268to the associated :math:`Y^j`. A line joins all the marks. Thus, each point of
269the sample corresponds to a particular line on the graph.
270
271The scale of the axes are quantile based : each axe runs between 0 and 1 and
272each value is represented by its quantile with respect to its marginal
273empirical distribution.
274
275It is interesting to select, among those lines, the ones which correspond to a
276specific range of the output variable. These particular lines selected are
277colored differently in *color*. This specific range is defined with *Ymin* and
278*Ymax* in the quantile based scale of :math:`Y` or in its specific scale. In
279that second case, the range is automatically converted into a quantile based
280scale range.
281
282Examples
283--------
284>>> import openturns as ot
285>>> from openturns.viewer import View
286
287Generate a random sample from a Normal distribution:
288
289>>> ot.RandomGenerator.SetSeed(0)
290>>> inputSample = ot.Normal(2).getSample(15)
291>>> inputSample.setDescription(['X0', 'X1'])
292>>> formula = ['cos(X0)+cos(2*X1)']
293>>> model = ot.SymbolicFunction(['X0', 'X1'], formula)
294>>> outputSample = model(inputSample)
295
296Draw a parallel plot:
297
298>>> parplot = ot.VisualTest.DrawParallelCoordinates(inputSample, outputSample, 1.0, 2.0, 'red', False)
299>>> View(parplot).show()"
300
301// ---------------------------------------------------------------------
302
303%feature("docstring") OT::VisualTest::DrawKendallPlot
304"Draw kendall plot.
305
306Refer to :ref:`graphical_fitting_test`.
307
308Available usages:
309    VisualTest.DrawKendallPlot(*sample, distribution*)
310
311    VisualTest.DrawKendallPlot(*sample, sample2*)
312
313Parameters
314----------
315sample, sample2 : 2-d sequence of float
316    Samples to draw.
317distribution : :class:`~openturns.Distribution`
318    Distribution used to plot the second cloud
319
320Returns
321-------
322graph : :class:`~openturns.Graph`
323    The graph object
324
325Examples
326--------
327>>> import openturns as ot
328>>> from openturns.viewer import View
329>>> ot.RandomGenerator.SetSeed(0)
330>>> size = 100
331>>> copula1 = ot.FrankCopula(1.5)
332>>> copula2 = ot.GumbelCopula(4.5)
333>>> sample1 = copula1.getSample(size)
334>>> sample1.setName('data 1')
335>>> sample2 = copula2.getSample(size)
336>>> sample2.setName('data 2')
337>>> kendallPlot1 = ot.VisualTest.DrawKendallPlot(sample1, copula2)
338>>> View(kendallPlot1).show()"
339
340// ---------------------------------------------------------------------
341
342%feature("docstring") OT::VisualTest::DrawLinearModel
343"Plot a 1D linear model.
344
345Parameters
346----------
347inputSample, outputSample : 2-d sequence of float (optional)
348    X and Y coordinates of the points the test is to be performed on.
349    If *inputSample* and *outputSample* were the training samples
350    of the linear model, there is no need to supply them (see example below).
351linearModelResult : :class:`~openturns.LinearModelResult`
352    Linear model to plot.
353
354Returns
355-------
356graph : :class:`~openturns.Graph`
357    The graph object
358
359Examples
360--------
361>>> import openturns as ot
362>>> from openturns.viewer import View
363>>> ot.RandomGenerator.SetSeed(0)
364>>> dimension = 2
365>>> R = ot.CorrelationMatrix(dimension)
366>>> R[0, 1] = 0.8
367>>> distribution = ot.Normal([3.0] * dimension, [2.0]* dimension, R)
368>>> size = 200
369>>> sample2D = distribution.getSample(size)
370>>> firstSample = ot.Sample(size, 1)
371>>> secondSample = ot.Sample(size, 1)
372>>> for i in range(size):
373...     firstSample[i] = ot.Point(1, sample2D[i, 0])
374...     secondSample[i] = ot.Point(1, sample2D[i, 1])
375>>> # Generate training Samples
376>>> inputTrainSample = firstSample[0:size//2]
377>>> outputTrainSample = secondSample[0:size//2]
378>>> # Generate test Samples
379>>> inputTestSample = firstSample[size//2:]
380>>> outputTestSample = secondSample[size//2:]
381>>> # Define and get the result of the linear model
382>>> lmtest = ot.LinearModelAlgorithm(inputTrainSample, outputTrainSample).getResult()
383>>> # Visual test on the training samples: no need to supply them again
384>>> drawLinearModelVTest = ot.VisualTest.DrawLinearModel(lmtest)
385>>> View(drawLinearModelVTest).show()
386>>> # Visual test on the test samples
387>>> drawLinearModelVTest2 = ot.VisualTest.DrawLinearModel(inputTestSample, outputTestSample, lmtest)
388>>> View(drawLinearModelVTest2).show()"
389
390// ---------------------------------------------------------------------
391
392%feature("docstring") OT::VisualTest::DrawLinearModelResidual
393"Plot a 1D linear model's residuals.
394
395Parameters
396----------
397inputSample, outputSample : 2-d sequence of float, optional
398    X and Y coordinates of the points the test is to be performed on.
399    If *inputSample* and *outputSample* were the training samples
400    of the linear model, there is no need to supply them (see example below).
401linearModelResult : :class:`~openturns.LinearModelResult`
402    Linear model to plot.
403
404Returns
405-------
406graph : :class:`~openturns.Graph`
407    The graph object
408
409Examples
410--------
411>>> import openturns as ot
412>>> from openturns.viewer import View
413>>> ot.RandomGenerator.SetSeed(0)
414>>> dimension = 2
415>>> R = ot.CorrelationMatrix(dimension)
416>>> R[0, 1] = 0.8
417>>> distribution = ot.Normal([3.0] * dimension, [2.0]* dimension, R)
418>>> size = 200
419>>> sample2D = distribution.getSample(size)
420>>> firstSample = ot.Sample(size, 1)
421>>> secondSample = ot.Sample(size, 1)
422>>> for i in range(size):
423...     firstSample[i] = ot.Point(1, sample2D[i, 0])
424...     secondSample[i] = ot.Point(1, sample2D[i, 1])
425>>> # Generate training Samples
426>>> inputTrainSample = firstSample[0:size//2]
427>>> outputTrainSample = secondSample[0:size//2]
428>>> # Generate test Samples
429>>> inputTestSample = firstSample[size//2:]
430>>> outputTestSample = secondSample[size//2:]
431>>> # Define and get the result of the linear model
432>>> lmtest = ot.LinearModelAlgorithm(inputTrainSample, outputTrainSample).getResult()
433>>> # Visual test on the training samples: no need to supply them again
434>>> drawLinearModelVTest = ot.VisualTest.DrawLinearModelResidual(lmtest)
435>>> View(drawLinearModelVTest).show()
436>>> # Visual test on the test samples
437>>> drawLinearModelVTest2 = ot.VisualTest.DrawLinearModelResidual(inputTestSample, outputTestSample, lmtest)
438>>> View(drawLinearModelVTest2).show()"
439
440// ---------------------------------------------------------------------
441
442%feature("docstring") OT::VisualTest::DrawPairs
443"Draw 2-d projections of a multivariate sample.
444
445Parameters
446----------
447sample : 2-d sequence of float
448    Samples to draw.
449
450Returns
451-------
452graph : :class:`~openturns.Graph`
453    The graph object
454
455Notes
456-----
457The point style and the color are given by 'Drawable-DefaultPointStyle' and 'Drawable-DefaultColor' keys in :class:`~openturns.ResourceMap`.
458
459Examples
460--------
461>>> import openturns as ot
462>>> from openturns.viewer import View
463>>> ot.RandomGenerator.SetSeed(0)
464>>> dim = 3
465>>> R = ot.CorrelationMatrix(dim)
466>>> R[0, 1] = 0.8
467>>> distribution = ot.Normal([3.0] * dim, [2.0]* dim, R)
468>>> size = 100
469>>> sample = distribution.getSample(size)
470>>> clouds = ot.VisualTest.DrawPairs(sample)
471>>> View(clouds).show()"
472
473// ---------------------------------------------------------------------
474
475%feature("docstring") OT::VisualTest::DrawPairsMarginals
476"Draw 2-d projections of a multivariate sample plus marginals.
477
478Parameters
479----------
480sample : 2-d sequence of float
481    Samples to draw.
482distribution : :class:`~openturns.Distribution`
483    Distribution from which marginals are drawn
484
485Returns
486-------
487graph : :class:`~openturns.Graph`
488    The graph object
489
490Examples
491--------
492>>> import openturns as ot
493>>> from openturns.viewer import View
494>>> ot.RandomGenerator.SetSeed(0)
495>>> dim = 3
496>>> R = ot.CorrelationMatrix(dim)
497>>> R[0, 1] = 0.8
498>>> distribution = ot.Normal([3.0] * dim, [2.0]* dim, R)
499>>> size = 100
500>>> sample = distribution.getSample(size)
501>>> distribution = ot.ComposedDistribution([ot.HistogramFactory().build(sample.getMarginal(i)) for i in range(dim)])
502>>> clouds = ot.VisualTest.DrawPairsMarginals(sample, distribution)
503>>> View(clouds).show()"
504
505