File wellmet/g_models.py changed (mode: 100644) (index aadb119..b8d7311) |
... |
... |
class Linear_nD: |
176 |
176 |
return (Ingot(bound_R),) |
return (Ingot(bound_R),) |
177 |
177 |
|
|
178 |
178 |
|
|
|
179 |
|
class X1: |
|
180 |
|
""" |
|
181 |
|
suma velicin plus beta*sqrt(Nvar. ) |
|
182 |
|
Pro IID Gaussian ma tohle ind. spol. beta = beta |
|
183 |
|
The same as Linear_nD, but defined via |
|
184 |
|
beta in sense of reliability index |
|
185 |
|
""" |
|
186 |
|
def __init__(self, beta_exact): |
|
187 |
|
self._beta_exact = beta_exact |
|
188 |
|
|
|
189 |
|
# sign |
|
190 |
|
def __repr__(self): |
|
191 |
|
return 'X1(%s)' % repr(self._beta_exact) |
|
192 |
|
|
|
193 |
|
def __call__(self, input_sample): |
|
194 |
|
# očekávam, že get_R_coordinates mně vrátí 2D pole |
|
195 |
|
sample = get_R_coordinates(input_sample) |
|
196 |
|
g = -sample[:, 0] + self._beta_exact |
|
197 |
|
return SampleBox(input_sample, g, repr(self)) |
|
198 |
|
|
|
199 |
|
# Fence off! |
|
200 |
|
def get_2D_R_boundary(self, nrod=100, xlim=(-5,5), ylim=(-5,5), *args): |
|
201 |
|
""" |
|
202 |
|
Fence off! |
|
203 |
|
nrod - number of rods in fencing |
|
204 |
|
""" |
|
205 |
|
|
|
206 |
|
bound_R = np.empty((nrod, 2)) |
|
207 |
|
bound_R[:, 0] = self._beta_exact |
|
208 |
|
bound_R[:, 1] = np.linspace(ylim[0], ylim[1], nrod, endpoint=True) |
|
209 |
|
# tuple of tuple |
|
210 |
|
return (Ingot(bound_R),) |
|
211 |
|
|
|
212 |
|
|
|
213 |
|
class AbsX1: |
|
214 |
|
""" |
|
215 |
|
suma velicin plus beta*sqrt(Nvar. ) |
|
216 |
|
Pro IID Gaussian ma tohle ind. spol. beta = beta |
|
217 |
|
The same as Linear_nD, but defined via |
|
218 |
|
beta in sense of reliability index |
|
219 |
|
""" |
|
220 |
|
def __init__(self, beta_exact): |
|
221 |
|
self._beta_exact = beta_exact |
|
222 |
|
|
|
223 |
|
# sign |
|
224 |
|
def __repr__(self): |
|
225 |
|
return 'X1(%s)' % repr(self._beta_exact) |
|
226 |
|
|
|
227 |
|
def __call__(self, input_sample): |
|
228 |
|
# očekávam, že get_R_coordinates mně vrátí 2D pole |
|
229 |
|
sample = get_R_coordinates(input_sample) |
|
230 |
|
g = -np.abs(sample[:, 0]) + self._beta_exact |
|
231 |
|
return SampleBox(input_sample, g, repr(self)) |
|
232 |
|
|
|
233 |
|
# Fence off! |
|
234 |
|
def get_2D_R_boundary(self, nrod=100, xlim=(-5,5), ylim=(-5,5), *args): |
|
235 |
|
""" |
|
236 |
|
Fence off! |
|
237 |
|
nrod - number of rods in fencing |
|
238 |
|
""" |
|
239 |
|
|
|
240 |
|
bound_R = np.empty((nrod, 2)) |
|
241 |
|
bound_R[:, 0] = self._beta_exact |
|
242 |
|
bound_R[:, 1] = np.linspace(ylim[0], ylim[1], nrod, endpoint=True) |
|
243 |
|
# tuple of tuple |
|
244 |
|
return (Ingot(bound_R), Ingot(-bound_R)) |
|
245 |
|
|
|
246 |
|
|
179 |
247 |
class Z_sum: |
class Z_sum: |
180 |
248 |
""" |
""" |
181 |
249 |
suma velicin plus beta*sqrt(Nvar. ) |
suma velicin plus beta*sqrt(Nvar. ) |
File wellmet/testcases/testcases_nD.py changed (mode: 100644) (index 4600f59..63ffbe6) |
... |
... |
def snorm_neverfall(ndim): |
30 |
30 |
return whitebox.WhiteBox(f_models.SNorm(ndim), gm.neverfall) |
return whitebox.WhiteBox(f_models.SNorm(ndim), gm.neverfall) |
31 |
31 |
|
|
32 |
32 |
|
|
|
33 |
|
add('snorm_line_pf6') |
|
34 |
|
def snorm_line_pf6(ndim): |
|
35 |
|
return whitebox.Line(ndim, -stats.norm.ppf(1e-6)) |
|
36 |
|
|
|
37 |
|
add('snorm_twoline_pf6') |
|
38 |
|
def snorm_twoline_pf6(ndim): |
|
39 |
|
return whitebox.TwoLine(ndim, -stats.norm.ppf(1e-6 / 2)) |
|
40 |
|
|
|
41 |
|
|
33 |
42 |
# HyperRovina, куда ж без неё? |
# HyperRovina, куда ж без неё? |
34 |
43 |
# Gauß |
# Gauß |
35 |
44 |
add('hyperplane_pf3') |
add('hyperplane_pf3') |
File wellmet/whitebox.py changed (mode: 100644) (index 3699614..9b87bb9) |
... |
... |
class HyperPlane(WhiteBox): # куда ж без него... |
287 |
287 |
|
|
288 |
288 |
def __repr__(wt): |
def __repr__(wt): |
289 |
289 |
return 'HyperPlane(%s)' % repr(wt._betas) |
return 'HyperPlane(%s)' % repr(wt._betas) |
|
290 |
|
|
|
291 |
|
|
|
292 |
|
class Line(WhiteBox): |
|
293 |
|
def __init__(self, nvar=2, beta=5): |
|
294 |
|
""" |
|
295 |
|
Class takes for inicialization tuple of betas |
|
296 |
|
Betas are coeffitients in sense of Regression Analysis (well, not really) |
|
297 |
|
g= a*X1 + b*X2 + c |
|
298 |
|
betas=(a,b,c) |
|
299 |
|
""" |
|
300 |
|
self.beta_exact = beta |
|
301 |
|
self.gm = g_models.X1(beta) |
|
302 |
|
self.f = f_models.SNorm(nvar) |
|
303 |
|
# na začatku nemáme vzorky - pouze rozdělení a podpís |
|
304 |
|
self.sample_box = SampleBox(self.f(), gm_signature=self.gm_signature) |
|
305 |
|
|
|
306 |
|
self.pf_exact = stats.norm.cdf(-beta) |
|
307 |
|
self.pf_exact_method = 'FORM (exact solution)' # Ang, Tang and Pythagoras |
|
308 |
|
|
|
309 |
|
|
|
310 |
|
def __str__(wt): |
|
311 |
|
return 'Line%sD' % wt.f.nvar |
|
312 |
|
|
|
313 |
|
def __repr__(wt): |
|
314 |
|
return 'Line(%s, %s)' % repr(wt.f.nvar, wt.beta_exact) |
|
315 |
|
|
|
316 |
|
class TwoLine(WhiteBox): |
|
317 |
|
def __init__(self, nvar=2, beta=5): |
|
318 |
|
""" |
|
319 |
|
Class takes for inicialization tuple of betas |
|
320 |
|
Betas are coeffitients in sense of Regression Analysis (well, not really) |
|
321 |
|
g= a*X1 + b*X2 + c |
|
322 |
|
betas=(a,b,c) |
|
323 |
|
""" |
|
324 |
|
self.beta = beta |
|
325 |
|
self.gm = g_models.AbsX1(beta) |
|
326 |
|
self.f = f_models.SNorm(nvar) |
|
327 |
|
# na začatku nemáme vzorky - pouze rozdělení a podpís |
|
328 |
|
self.sample_box = SampleBox(self.f(), gm_signature=self.gm_signature) |
|
329 |
|
|
|
330 |
|
self.pf_exact = stats.norm.cdf(-beta) * 2 |
|
331 |
|
self.pf_exact_method = '2FORM (exact solution)' # Ang, Tang and Pythagoras |
|
332 |
|
|
|
333 |
|
|
|
334 |
|
def __str__(wt): |
|
335 |
|
return 'TwoLine%sD' % wt.f.nvar |
|
336 |
|
|
|
337 |
|
def __repr__(wt): |
|
338 |
|
return 'TwoLine(%s, %s)' % repr(wt.f.nvar, wt.beta) |
290 |
339 |
|
|
291 |
340 |
|
|
292 |
341 |
class Gaussian_Z_sum(WhiteBox): #ё куда ж без этого... |
class Gaussian_Z_sum(WhiteBox): #ё куда ж без этого... |