File wellmet/g_models.py changed (mode: 100644) (index cd28f59..9043bae) |
... |
... |
class Z_prod: |
342 |
342 |
|
|
343 |
343 |
|
|
344 |
344 |
|
|
|
345 |
|
class Z_hyperbola: |
|
346 |
|
""" |
|
347 |
|
soucin velicin plus nějaká konstanta |
|
348 |
|
# g= s * (X1 * X2 * X3 * X4 + c ) |
|
349 |
|
""" |
|
350 |
|
# tenhle model ani nvar si neukladá, tohle vůbec neřeší |
|
351 |
|
def __init__(self, const=0): |
|
352 |
|
self._const = const |
|
353 |
|
|
|
354 |
|
# sign |
|
355 |
|
def __repr__(self): |
|
356 |
|
return 'Z_hyperbola(%s)' % self._const |
|
357 |
|
|
|
358 |
|
def __call__(self, input_sample): |
|
359 |
|
# očekávam, že get_R_coordinates mně vrátí 2D pole |
|
360 |
|
sample = get_R_coordinates(input_sample) |
|
361 |
|
g = self._const - np.all(sample > 0, axis=1) * np.prod(sample, axis=1) |
|
362 |
|
return SampleBox(input_sample, g, repr(self)) |
|
363 |
|
|
|
364 |
|
# Fence off! |
|
365 |
|
def get_2D_R_boundary(self, nrod=100, *args): |
|
366 |
|
""" |
|
367 |
|
Fence off! |
|
368 |
|
nrod - number of rods in fencing |
|
369 |
|
""" |
|
370 |
|
# g= X1 * X2 + c |
|
371 |
|
# |
|
372 |
|
# a^2 = 2*X^2 |
|
373 |
|
# a=b= X * sqrt(2) |
|
374 |
|
# a^2 = 2*c |
|
375 |
|
# r = a*b / np.sqrt(b**2 * np.cos(phi)**2 - a**2 * np.sin(phi)**2) |
|
376 |
|
|
|
377 |
|
c = -self._const |
|
378 |
|
_c = -1 |
|
379 |
|
#č náš oblibený trik - hranici nakreslime pomoci polárních souřádnic |
|
380 |
|
phi = np.linspace(0.25*np.pi, (0.25+_c/2)*np.pi, nrod , endpoint=False)[1:] |
|
381 |
|
r = np.sqrt(2*c / (np.sin(phi)**2 - np.cos(phi)**2)) |
|
382 |
|
bound_x_left = r * np.cos(phi+np.pi/4) |
|
383 |
|
bound_y_left = r * np.sin(phi+np.pi/4) |
|
384 |
|
|
|
385 |
|
# phi = np.linspace(-0.75*np.pi, (_c/2-0.75)*np.pi, nrod , endpoint=False)[1:] |
|
386 |
|
# r = np.sqrt(2*c / (np.sin(phi)**2 - np.cos(phi)**2)) |
|
387 |
|
# bound_x_right = r * np.cos(phi+np.pi/4) |
|
388 |
|
# bound_y_right = r * np.sin(phi+np.pi/4) |
|
389 |
|
|
|
390 |
|
# sample compatible |
|
391 |
|
# малы транспонировать кароно? Озьы кулэ! |
|
392 |
|
bound_R_left = np.array((bound_x_left, bound_y_left)).T |
|
393 |
|
#bound_R_right = np.array((bound_x_right, bound_y_right)).T |
|
394 |
|
# tuple of samples |
|
395 |
|
return (Ingot(bound_R_left), ) #Ingot(bound_R_right)) |
|
396 |
|
|
|
397 |
|
|
345 |
398 |
class Z_min: |
class Z_min: |
346 |
399 |
""" |
""" |
347 |
400 |
min velicin plus nějaká konstanta |
min velicin plus nějaká konstanta |
File wellmet/testcases/gaussian_2D.py changed (mode: 100644) (index b30a311..99940ff) |
... |
... |
from ..whitebox import WhiteBox, Gaussian_Z_prod_2D |
14 |
14 |
from ..whitebox import Gaussian_ProdFourBetas_2D |
from ..whitebox import Gaussian_ProdFourBetas_2D |
15 |
15 |
from ..whitebox import Gaussian_Z_sumexp_2D |
from ..whitebox import Gaussian_Z_sumexp_2D |
16 |
16 |
from ..whitebox import Gaussian_Z_max |
from ..whitebox import Gaussian_Z_max |
|
17 |
|
from ..whitebox import Gaussian_Hyperbola_2D |
17 |
18 |
|
|
18 |
19 |
__all__ = [] |
__all__ = [] |
19 |
20 |
|
|
|
... |
... |
def prod_03(): |
102 |
103 |
def prod_5(): |
def prod_5(): |
103 |
104 |
return Gaussian_Z_prod_2D(const=-5, sign=-1) |
return Gaussian_Z_prod_2D(const=-5, sign=-1) |
104 |
105 |
|
|
|
106 |
|
add('hyperbola_2') |
|
107 |
|
def hyperbola_2(): |
|
108 |
|
return Gaussian_Hyperbola_2D(const=2) |
105 |
109 |
|
|
106 |
110 |
|
|
107 |
111 |
class ProxyProd: |
class ProxyProd: |
File wellmet/whitebox.py changed (mode: 100644) (index 0a36430..0dff08c) |
... |
... |
class Gaussian_Z_prod_2D(WhiteBox): |
472 |
472 |
def __repr__(wt): |
def __repr__(wt): |
473 |
473 |
return 'Gaussian_Z_prod_2D(const=%s)' % wt.const |
return 'Gaussian_Z_prod_2D(const=%s)' % wt.const |
474 |
474 |
|
|
|
475 |
|
|
|
476 |
|
|
|
477 |
|
class Gaussian_Hyperbola_2D(WhiteBox): |
|
478 |
|
def __init__(self, **kwargs): |
|
479 |
|
""" |
|
480 |
|
Breitung RESS 182 (2019) p. 99 |
|
481 |
|
""" |
|
482 |
|
if 'const' in kwargs: |
|
483 |
|
self.const = kwargs['const'] |
|
484 |
|
elif 'beta' in kwargs: |
|
485 |
|
self.beta = kwargs['beta'] |
|
486 |
|
self.const = self.beta**2/2 |
|
487 |
|
else: |
|
488 |
|
raise ValueError |
|
489 |
|
|
|
490 |
|
|
|
491 |
|
#č g-modelu je to samozřejmě šuma, ale bílá skříňka nechť raději |
|
492 |
|
#č pečlivěji zpracovává vstup |
|
493 |
|
self.gm = g_models.Z_hyperbola(self.const) |
|
494 |
|
self.f = f_models.SNorm(2) |
|
495 |
|
#č na začatku nemáme vzorky - pouze rozdělení a podpís |
|
496 |
|
self.sample_box = SampleBox(self.f(), gm_signature=self.gm_signature) |
|
497 |
|
#č Rozdělení transformovaného náhodného čísla je zadano jako |
|
498 |
|
# special.kn(0, np.abs(x)) / np.pi # Breitung RESS 182 (2019) p. 99 |
|
499 |
|
# kn(n, x) Modified Bessel function of the second kind of integer order n |
|
500 |
|
# modstruve(v, x) Modified Struve function of order v at x |
|
501 |
|
#č Odvození pf_exact z Maple |
|
502 |
|
#self.pf_exact = 0.5 - const/2 * (StruveL1 * BesselK0 + StruveL0 * BesselK1 + 2/np.pi * BesselK0) |
|
503 |
|
self.pf_exact = gauss_prod_CDF(-self.const) / 2 |
|
504 |
|
self.pf_exact_method = 'exact (Bessel) solution' |
|
505 |
|
self.r_exact = np.sqrt(np.abs(self.const) * 2) |
|
506 |
|
|
|
507 |
|
def __str__(wt): |
|
508 |
|
return 'Gaussian_Hyperbola_2D' |
|
509 |
|
|
|
510 |
|
def __repr__(wt): |
|
511 |
|
return 'Gaussian_Hyperbola_2D(const=%s)' % wt.const |
|
512 |
|
|
|
513 |
|
|
475 |
514 |
#č já jsem si najednou uvědomil, že v tomto modulu |
#č já jsem si najednou uvědomil, že v tomto modulu |
476 |
515 |
#č mám náprosto hrozný mix Camel- a snailcas'u. |
#č mám náprosto hrozný mix Camel- a snailcas'u. |
477 |
516 |
#č Výmluvím z toho tak, podtržitko odděluje rozdělení a nazev g-modelu |
#č Výmluvím z toho tak, podtržitko odděluje rozdělení a nazev g-modelu |