File whitebox.py changed (mode: 100644) (index 1a28174..a7f4909) |
... |
... |
whitebox actually IS g_model PLUS: |
21 |
21 |
""" |
""" |
22 |
22 |
import numpy as np |
import numpy as np |
23 |
23 |
from scipy import stats |
from scipy import stats |
24 |
|
from scipy import special # for S_ball |
|
|
24 |
|
from scipy import special # for S_ball # for Z_prod |
25 |
25 |
from scipy import integrate # for S_ball |
from scipy import integrate # for S_ball |
26 |
26 |
|
|
27 |
27 |
import mpmath # for Gaussian_Z_min |
import mpmath # for Gaussian_Z_min |
|
... |
... |
class Gaussian_Z_sum(WhiteBox): #ё куда ж без этого... |
311 |
311 |
return 'Gaussian_Z_sum(nvar=%s, beta_exact=%s)' % (wt.f.nvar, wt.beta_exact) |
return 'Gaussian_Z_sum(nvar=%s, beta_exact=%s)' % (wt.f.nvar, wt.beta_exact) |
312 |
312 |
|
|
313 |
313 |
|
|
|
314 |
|
class Gaussian_Z_prod_2D(WhiteBox): |
|
315 |
|
def __init__(self, **kwargs): |
|
316 |
|
""" |
|
317 |
|
Breitung RESS 182 (2019) p. 99 |
|
318 |
|
""" |
|
319 |
|
#č měníme logiku. |
|
320 |
|
#č u této třídy známenko constanty bude ovlivňovat |
|
321 |
|
#č poruchové kvadranty. |
|
322 |
|
if 'const' in kwargs: |
|
323 |
|
self.const = kwargs['const'] |
|
324 |
|
elif 'beta' in kwargs: |
|
325 |
|
self.beta = kwargs['beta'] |
|
326 |
|
self.const = self.beta**2/2 |
|
327 |
|
else: |
|
328 |
|
raise ValueError |
|
329 |
|
|
|
330 |
|
|
|
331 |
|
#č g-modelu je to samozřejmě šuma, ale bílá skříňka nechť raději |
|
332 |
|
#č pečlivěji zpracovává vstup |
|
333 |
|
self.gm = g_models.Z_prod(const=self.const, sign=np.sign(self.const)) |
|
334 |
|
self.f = f_models.SNorm(2) |
|
335 |
|
#č na začatku nemáme vzorky - pouze rozdělení a podpís |
|
336 |
|
self.sample_box = SampleBox(self.f(), gm_signature=self.gm_signature) |
|
337 |
|
#č Rozdělení transformovaného náhodného čísla je zadano jako |
|
338 |
|
# special.kn(0, np.abs(x)) / np.pi # Breitung RESS 182 (2019) p. 99 |
|
339 |
|
# kn(n, x) Modified Bessel function of the second kind of integer order n |
|
340 |
|
# modstruve(v, x) Modified Struve function of order v at x |
|
341 |
|
#č Odvození pf_exact z Maple |
|
342 |
|
const = np.abs(self.const) |
|
343 |
|
StruveL0 = special.modstruve(0, const) |
|
344 |
|
StruveL1 = special.modstruve(1, const) |
|
345 |
|
BesselK0 = special.kn(0, const) |
|
346 |
|
BesselK1 = special.kn(1, const) |
|
347 |
|
self.pf_exact = const/2 * (1/const - (StruveL1 * BesselK0 + StruveL0 * BesselK1 + 2/np.pi * BesselK0)) |
|
348 |
|
self.pf_exact_method = 'exact (Bessel) solution' |
|
349 |
|
|
|
350 |
|
|
|
351 |
|
def __str__(wt): |
|
352 |
|
return 'Gaussian_Z_prod_2D' |
|
353 |
|
|
|
354 |
|
def __repr__(wt): |
|
355 |
|
return 'Gaussian_Z_prod_2D(sign=%s, const=%s)' % (wt.sign, wt.const) |
|
356 |
|
|
|
357 |
|
|
314 |
358 |
class Lognormal_Z_prod(WhiteBox): #č ověřím to moje odvození... |
class Lognormal_Z_prod(WhiteBox): #č ověřím to moje odvození... |
315 |
359 |
def __init__(self, nvar=2, beta_exact=5, sign=1): |
def __init__(self, nvar=2, beta_exact=5, sign=1): |
316 |
360 |
""" |
""" |