File f_models.py changed (mode: 100644) (index 374874f..5a97b98) |
... |
... |
class Ingot: |
20 |
20 |
Prazdná třida pro "nevypalené" vzorky, tj. bez přiřazeného rozdělení |
Prazdná třida pro "nevypalené" vzorky, tj. bez přiřazeného rozdělení |
21 |
21 |
""" |
""" |
22 |
22 |
def __init__(self, data, attr='R'): |
def __init__(self, data, attr='R'): |
23 |
|
# data? takový neslaný nazev... |
|
24 |
|
# data suppose to be pandas compatible, i.e. |
|
25 |
|
# nsim, nvar = data.shape |
|
26 |
23 |
self.attr = attr |
self.attr = attr |
27 |
24 |
try: |
try: |
28 |
25 |
self.data = np.atleast_2d(getattr(data, attr)) |
self.data = np.atleast_2d(getattr(data, attr)) |
|
... |
... |
class Ingot: |
50 |
47 |
# Рекурсилы пезьдэт! |
# Рекурсилы пезьдэт! |
51 |
48 |
if attr in ('attr', 'data'): |
if attr in ('attr', 'data'): |
52 |
49 |
raise AttributeError(attr) |
raise AttributeError(attr) |
53 |
|
#if attr in ('R', 'Rn', 'GK', 'G', 'P', 'U') and attr==self.space: |
|
54 |
|
# return f._data |
|
55 |
50 |
elif attr == 'nvar': |
elif attr == 'nvar': |
56 |
51 |
nsim, nvar = self.data.shape |
nsim, nvar = self.data.shape |
57 |
52 |
return nvar |
return nvar |
|
... |
... |
class SNorm: |
135 |
130 |
def __getattr__(f, attr): |
def __getattr__(f, attr): |
136 |
131 |
if attr in ('pdf_R', 'pdf_Rn', 'pdf_GK', 'pdf_G'): |
if attr in ('pdf_R', 'pdf_Rn', 'pdf_GK', 'pdf_G'): |
137 |
132 |
return f._data[:,-1] |
return f._data[:,-1] |
|
133 |
|
elif attr in ('pdf_P', 'pdf_U'): |
|
134 |
|
return np.full(f.nsim, 1) |
138 |
135 |
elif attr in ('R', 'Rn', 'GK', 'G'): |
elif attr in ('R', 'Rn', 'GK', 'G'): |
139 |
136 |
return f._data[:,:f.__nvar] |
return f._data[:,:f.__nvar] |
140 |
137 |
elif attr in ('P', 'U'): |
elif attr in ('P', 'U'): |
|
... |
... |
class SNorm: |
207 |
204 |
f_copy.add_sample(sample, space) |
f_copy.add_sample(sample, space) |
208 |
205 |
return f_copy |
return f_copy |
209 |
206 |
|
|
210 |
|
# # drobná pomucka |
|
211 |
|
# def new_random_sample(f, ns=1): |
|
212 |
|
# f_copy = eval(f.__repr__()) |
|
213 |
|
# f_copy.add_sample(np.random.random((ns, f.nvar)), 'U') |
|
214 |
|
# return f_copy |
|
215 |
|
|
|
216 |
207 |
|
|
217 |
208 |
|
|
218 |
209 |
|
|
219 |
|
|
|
220 |
|
|
|
221 |
210 |
class UnCorD: # nic moc nazev, ale je přece lepší nez CommonJointDistribution |
class UnCorD: # nic moc nazev, ale je přece lepší nez CommonJointDistribution |
222 |
211 |
""" |
""" |
223 |
212 |
Takes tuple of scipy stats distribution objects |
Takes tuple of scipy stats distribution objects |
|
... |
... |
class UnCorD: # nic moc nazev, ale je přece lepší nez CommonJointDistribution |
264 |
253 |
def __getattr__(f, attr): |
def __getattr__(f, attr): |
265 |
254 |
if attr == 'pdf_R': |
if attr == 'pdf_R': |
266 |
255 |
return f._data[:,-2] |
return f._data[:,-2] |
|
256 |
|
elif attr == 'pdf_Rn': |
|
257 |
|
return f._data[:,-2] * np.prod(list(f.marginals[i].std() for i in range(f.nvar))) |
267 |
258 |
elif attr in ('pdf_GK', 'pdf_G'): |
elif attr in ('pdf_GK', 'pdf_G'): |
268 |
259 |
return f._data[:,-1] |
return f._data[:,-1] |
|
260 |
|
elif attr in ('pdf_P', 'pdf_U'): |
|
261 |
|
return np.full(f.nsim, 1) |
269 |
262 |
elif attr == 'Rn': |
elif attr == 'Rn': |
270 |
263 |
return f.__frame(0) |
return f.__frame(0) |
271 |
264 |
elif attr == 'R': |
elif attr == 'R': |
|
... |
... |
class UnCorD: # nic moc nazev, ale je přece lepší nez CommonJointDistribution |
340 |
333 |
f_copy.add_sample(sample, space) |
f_copy.add_sample(sample, space) |
341 |
334 |
return f_copy |
return f_copy |
342 |
335 |
|
|
343 |
|
# # drobná pomucka |
|
344 |
|
# def new_random_sample(f, ns=1): |
|
345 |
|
# f_copy = f() |
|
346 |
|
# f_copy.add_sample(np.random.random((ns, f.nvar)), 'U') |
|
347 |
|
# return f_copy |
|
348 |
336 |
|
|
349 |
337 |
def _chain(f, sample_dict): |
def _chain(f, sample_dict): |
350 |
338 |
# chain tam |
# chain tam |