3636def _tracy_widom_cdf (x : float ) -> float :
3737 """
3838 Computes the CDF of the Tracy-Widom distribution (with beta = 1).
39+
40+ Parameters
41+ ----------
42+ x : float
43+ Value at which to evaluate the CDF.
44+
45+ Returns
46+ -------
47+ float
48+ The value of the CDF at x.
3949 """
4050 if x > 3 :
4151 tail_prob = np .exp (- 2.0 / 3.0 * x ** 1.5 ) / (4.0 * np .sqrt (np .pi ) * x ** 1.5 )
@@ -57,6 +67,17 @@ def _tracy_widom_cdf(x: float) -> float:
5767
5868def _calculate_statistics (X : np .ndarray ) -> float :
5969 """
70+ Calculates the test statistic for the Tracy-Widom distribution.
71+
72+ Parameters
73+ ----------
74+ X : np.ndarray
75+ Matrix of shape (n, p) containing the data.
76+
77+ Returns
78+ -------
79+ float
80+ The value of the test statistic.
6081 """
6182 n , p = X .shape
6283 X_centered = (X - np .mean (X , axis = 0 )) / np .std (X , axis = 0 )
@@ -85,6 +106,28 @@ def eigenvalue_test(
85106):
86107 """
87108 Performs Johnstone’s Spiked Covariance Test to identify if the embedding is random.
109+
110+ Parameters
111+ ----------
112+ adata : sc.AnnData | np.ndarray
113+ AnnData object or numpy array containing the data.
114+ key : str | None
115+ Key to use for AnnData input.
116+ key_added : str
117+ Key to use for adding the results to the AnnData object.
118+ flavor : Literal["asymptotic", "synthetic"]
119+ Flavor of the test to use.
120+ n_simulations : int
121+ Number of simulations to use for the synthetic approach.
122+ progress_bar : bool
123+ Whether to show a progress bar.
124+ null_distribution : np.ndarray | None
125+ Null distribution to use for the synthetic approach.
126+
127+ Returns
128+ -------
129+ dict
130+ Dictionary containing the test statistic and p-value.
88131 """
89132 start = logg .info (f"computing eigenvalues test via { flavor } approach" )
90133
0 commit comments