1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use ArrayView1;
use ;
/// Theoretical-vs-sample quantile pairs for a normal QQ plot of `residuals`.
///
/// For sorted residuals, observation `i` (1-indexed) is paired with the standard
/// normal quantile at plotting position `(i − 0.5) / n`. The returned pairs are
/// `(theoretical_quantile, sample_quantile)`, sorted ascending by sample value —
/// ready to scatter.
///
/// This crate produces the *data*, not the rendering. The natural pairing is with
/// [`plotters-statistical`](https://crates.io/crates/plotters-statistical)'s
/// scatter/reference-line primitives: a straight diagonal (`y = x`) is the
/// "perfect normality" baseline, conceptually the same role its `RocCurve`
/// diagonal plays. That is a documented cross-crate integration point, not a hard
/// dependency — pass the pairs into any plotting backend you like.
///
/// Typically you feed in standardized or studentized residuals so the diagonal
/// reference line has unit slope; raw residuals produce a line whose slope is the
/// residual standard deviation.
///
/// # Example
///
/// ```
/// use ndarray::array;
/// use regression_diagnostics::residuals::qq_plot_data;
///
/// let r = array![-1.2, 0.3, -0.1, 0.9, 0.05];
/// let pairs = qq_plot_data(r.view());
/// assert_eq!(pairs.len(), 5);
/// // Sample quantiles come out sorted ascending.
/// assert!(pairs.windows(2).all(|w| w[0].1 <= w[1].1));
/// ```