@@ -49,22 +49,22 @@ class EnergyDetector:
4949
5050 # def __init__(
5151 # self,
52- # N_nc : int,
52+ # n_nc : int,
5353 # p_fa: float = 1e-6,
5454 # streaming: bool = False,
5555 # ):
5656 # r"""
5757 # Initializes the energy detector.
5858
5959 # Arguments:
60- # N_nc : The number of samples $N_{nc}$ to non-coherently integrate.
60+ # n_nc : The number of samples $N_{nc}$ to non-coherently integrate.
6161 # p_fa: The desired probability of false alarm $P_{fa}$.
6262 # """
63- # if not isinstance(N_nc , int):
64- # raise TypeError(f"Argument 'N_nc ' must be an integer, not {type(N_nc )}.")
65- # if not N_nc >= 1:
66- # raise ValueError(f"Argument 'N_nc ' must be greater than or equal to 1, not {N_nc }.")
67- # self._N_nc = N_nc
63+ # if not isinstance(n_nc , int):
64+ # raise TypeError(f"Argument 'n_nc ' must be an integer, not {type(n_nc )}.")
65+ # if not n_nc >= 1:
66+ # raise ValueError(f"Argument 'n_nc ' must be greater than or equal to 1, not {n_nc }.")
67+ # self._N_nc = n_nc
6868
6969 # if not isinstance(p_fa, float):
7070 # raise TypeError(f"Argument 'p_fa' must be a float, not {type(p_fa)}.")
@@ -76,12 +76,12 @@ class EnergyDetector:
7676 # raise TypeError(f"Argument 'streaming' must be a bool, not {type(streaming)}.")
7777 # self._streaming = streaming
7878
79- # self._fir = FIR(np.ones(N_nc ), streaming=streaming)
79+ # self._fir = FIR(np.ones(n_nc ), streaming=streaming)
8080
8181 @staticmethod
8282 def roc (
8383 snr : float ,
84- N_nc : float ,
84+ n_nc : float ,
8585 p_fa : npt .ArrayLike | None = None ,
8686 complex : bool = True ,
8787 ) -> tuple [npt .NDArray [np .float64 ], npt .NDArray [np .float64 ]]:
@@ -90,7 +90,7 @@ def roc(
9090
9191 Arguments:
9292 snr: The received signal-to-noise ratio $\sigma_s^2 / \sigma^2$ in dB.
93- N_nc : The number of samples $N_{nc}$ to non-coherently integrate.
93+ n_nc : The number of samples $N_{nc}$ to non-coherently integrate.
9494 p_fa: The probability of false alarm $P_{fa}$. If `None`, the ROC curve is computed for
9595 `p_fa = np.logspace(-10, 0, 101)`.
9696 complex: Indicates whether the signal is complex.
@@ -125,20 +125,20 @@ def roc(
125125 sdr.plot.roc(*sdr.EnergyDetector.roc(-10, 5_000), label=f"N = 5,000");
126126 """
127127 verify_scalar (snr , float = True )
128- verify_scalar (N_nc , int = True , positive = True )
128+ verify_scalar (n_nc , int = True , positive = True )
129129 if p_fa is None :
130130 p_fa = np .logspace (- 10 , 0 , 101 )
131131 else :
132132 p_fa = verify_arraylike (p_fa , float = True , inclusive_min = 0 , inclusive_max = 1 )
133133
134- p_d = EnergyDetector .p_d (snr , N_nc , p_fa , complex = complex )
134+ p_d = EnergyDetector .p_d (snr , n_nc , p_fa , complex = complex )
135135
136136 return convert_output (p_fa ), convert_output (p_d )
137137
138138 @staticmethod
139139 def p_d (
140140 snr : npt .ArrayLike ,
141- N_nc : npt .ArrayLike ,
141+ n_nc : npt .ArrayLike ,
142142 p_fa : npt .ArrayLike ,
143143 complex : bool = True ,
144144 ) -> npt .NDArray [np .float64 ]:
@@ -147,7 +147,7 @@ def p_d(
147147
148148 Arguments:
149149 snr: The received signal-to-noise ratio $\sigma_s^2 / \sigma^2$ in dB.
150- N_nc : The number of samples $N_{nc}$ to non-coherently integrate.
150+ n_nc : The number of samples $N_{nc}$ to non-coherently integrate.
151151 p_fa: The probability of false alarm $P_{fa}$.
152152 complex: Indicates whether the signal is real or complex.
153153
@@ -184,16 +184,16 @@ def p_d(
184184 sdr.plot.p_d(snr, sdr.EnergyDetector.p_d(snr, 25, 1e-5), label="$P_{fa} = 10^{-5}$");
185185 """
186186 snr = verify_arraylike (snr , float = True )
187- N_nc = verify_arraylike (N_nc , int = True , positive = True )
187+ n_nc = verify_arraylike (n_nc , int = True , positive = True )
188188 p_fa = verify_arraylike (p_fa , float = True , inclusive_min = 0 , inclusive_max = 1 )
189189
190190 snr_linear = linear (snr )
191191 if not complex :
192- nu = N_nc # Degrees of freedom
192+ nu = n_nc # Degrees of freedom
193193 gamma_dprime = scipy .stats .chi2 .isf (p_fa , nu ) # Normalized threshold
194194 p_d = scipy .stats .chi2 .sf (gamma_dprime / (snr_linear + 1 ), nu )
195195 else :
196- nu = 2 * N_nc # Degrees of freedom
196+ nu = 2 * n_nc # Degrees of freedom
197197 gamma_dprime = scipy .stats .chi2 .isf (p_fa , nu ) # Normalized threshold
198198 p_d = scipy .stats .chi2 .sf (gamma_dprime / (snr_linear + 1 ), nu )
199199
@@ -202,7 +202,7 @@ def p_d(
202202 @staticmethod
203203 def p_fa (
204204 threshold : npt .ArrayLike ,
205- N_nc : npt .ArrayLike ,
205+ n_nc : npt .ArrayLike ,
206206 sigma2 : npt .ArrayLike ,
207207 complex : bool = True ,
208208 ) -> npt .NDArray [np .float64 ]:
@@ -211,7 +211,7 @@ def p_fa(
211211
212212 Arguments:
213213 threshold: The threshold $\gamma'$.
214- N_nc : The number of samples $N_{nc}$ to non-coherently integrate.
214+ n_nc : The number of samples $N_{nc}$ to non-coherently integrate.
215215 sigma2: The noise variance $\sigma^2$.
216216 complex: Indicates whether the signal is complex.
217217
@@ -232,21 +232,21 @@ def p_fa(
232232 Equation 5.2.
233233 """
234234 threshold = verify_arraylike (threshold , float = True )
235- N_nc = verify_arraylike (N_nc , int = True , positive = True )
235+ n_nc = verify_arraylike (n_nc , int = True , positive = True )
236236 sigma2 = verify_arraylike (sigma2 , float = True , non_negative = True )
237237
238238 if not complex :
239- nu = N_nc # Degrees of freedom
239+ nu = n_nc # Degrees of freedom
240240 p_fa = scipy .stats .chi2 .sf (threshold / sigma2 , nu )
241241 else :
242- nu = 2 * N_nc # Degrees of freedom
242+ nu = 2 * n_nc # Degrees of freedom
243243 p_fa = scipy .stats .chi2 .sf (threshold / (sigma2 / 2 ), nu )
244244
245245 return convert_output (p_fa )
246246
247247 @staticmethod
248248 def threshold (
249- N_nc : npt .ArrayLike ,
249+ n_nc : npt .ArrayLike ,
250250 p_fa : npt .ArrayLike ,
251251 sigma2 : npt .ArrayLike ,
252252 complex : bool = True ,
@@ -255,7 +255,7 @@ def threshold(
255255 Computes the threshold $\gamma'$.
256256
257257 Arguments:
258- N_nc : The number of samples $N_{nc}$ to non-coherently integrate.
258+ n_nc : The number of samples $N_{nc}$ to non-coherently integrate.
259259 p_fa: The probability of false alarm $P_{fa}$.
260260 sigma2: The noise variance $\sigma^2$.
261261 complex: Indicates whether the signal is complex.
@@ -276,15 +276,15 @@ def threshold(
276276 - Steven Kay, *Fundamentals of Statistical Signal Processing: Detection Theory*,
277277 Equation 5.2.
278278 """
279- N_nc = verify_arraylike (N_nc , int = True , positive = True )
279+ n_nc = verify_arraylike (n_nc , int = True , positive = True )
280280 p_fa = verify_arraylike (p_fa , float = True , inclusive_min = 0 , inclusive_max = 1 )
281281 sigma2 = verify_arraylike (sigma2 , float = True , non_negative = True )
282282
283283 if not complex :
284- nu = N_nc # Degrees of freedom
284+ nu = n_nc # Degrees of freedom
285285 gamma_prime = sigma2 * scipy .stats .chi2 .isf (p_fa , nu )
286286 else :
287- nu = 2 * N_nc # Degrees of freedom
287+ nu = 2 * n_nc # Degrees of freedom
288288 gamma_prime = sigma2 / 2 * scipy .stats .chi2 .isf (p_fa , nu )
289289
290290 return convert_output (gamma_prime )
@@ -318,11 +318,11 @@ def threshold(
318318 # The decision statistic $d$.
319319 # """
320320 # T = self.test_statistic(x)
321- # gamma = self.threshold(self.N_nc , self.desired_p_fa, sigma2)
321+ # gamma = self.threshold(self.n_nc , self.desired_p_fa, sigma2)
322322 # return T >= gamma
323323
324324 # @property
325- # def N_nc (self) -> int:
325+ # def n_nc (self) -> int:
326326 # """
327327 # The number of samples $N_{nc}$ to non-coherently integrate.
328328 # """
0 commit comments