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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Random projection depth measures.
use crateDim;
use crateFdMatrix;
use random_depth_core;
/// Compute random projection depth for 1D functional data.
///
/// Projects curves to scalars using random projections and computes
/// average univariate depth.
///
/// # Arguments
/// * `data_obj` - Data to compute depth for
/// * `data_ori` - Reference data
/// * `nproj` - Number of random projections
///
/// # Examples
///
/// ```
/// use fdars_core::matrix::FdMatrix;
/// use fdars_core::depth::random_projection;
/// use fdars_core::dim::Dim;
///
/// let data = FdMatrix::from_column_major(
/// (0..50).map(|i| (i as f64 * 0.1).sin()).collect(),
/// 5, 10,
/// ).unwrap();
/// let depths = random_projection(&data, &data, 50, Dim::One);
/// assert_eq!(depths.len(), 5);
/// assert!(depths.iter().all(|&d| d >= 0.0));
/// ```
pub
/// Compute random projection depth with optional seed for reproducibility.
/// Compute random projection depth for 1D or 2D functional data via a unified [`Dim`] dispatch.
///
/// The 2D path never diverged from the 1D one, so both [`Dim`] arms forward to
/// [`random_projection_1d`]. Because `random_projection_1d` draws fresh entropy
/// from `thread_rng()` (no public seed), the forwarding is a compile-time
/// guarantee (single-arm `match`), not a runtime-equality one; use
/// [`random_projection_1d_seeded`] for reproducible results.
///
/// # Arguments
/// * `data_obj` - Data to compute depth for
/// * `data_ori` - Reference data
/// * `nproj` - Number of random projections
/// * `dim` - Dimensionality selector ([`Dim::One`] or [`Dim::Two`])