File simplex.py changed (mode: 100644) (index 631c3ec..ed37e05) |
... |
... |
from .candybox import CandyBox |
13 |
13 |
#č Dostávám za to peníze. |
#č Dostávám za to peníze. |
14 |
14 |
#č Takže. Udělám 3 druhů estimátorů |
#č Takže. Udělám 3 druhů estimátorů |
15 |
15 |
# convex_hull_estimation -2: inside, -1: outside |
# convex_hull_estimation -2: inside, -1: outside |
16 |
|
# ghull_estimation -22: pith, -21: heartwood, -12: sapwood, -11: bark |
|
17 |
|
# shell_estimation -22: inner, -20: shell, -11: outer |
|
|
16 |
|
# shell_estimation -22: inner, -3: shell, -11: outer |
|
17 |
|
# ghull_estimation -22: inner, -21: shell inside, -12: shell outside, -11: outer |
18 |
18 |
class Ghull: |
class Ghull: |
19 |
19 |
def __init__(self, sample, incremental=True, design=None): |
def __init__(self, sample, incremental=True, design=None): |
20 |
20 |
self.sample = sample |
self.sample = sample |
|
... |
... |
class Ghull: |
62 |
62 |
R = self.get_R() |
R = self.get_R() |
63 |
63 |
shell.set_bounds(r, R) |
shell.set_bounds(r, R) |
64 |
64 |
|
|
65 |
|
# shell_estimation -22: inner, -20: shell, -11: outer |
|
66 |
|
shell_estimation = {-22:shell.ps, -20: shell.p_shell, -11: shell.pf} |
|
|
65 |
|
# shell_estimation -22: inner, -3: shell, -11: outer |
|
66 |
|
shell_estimation = {-22:shell.ps, -3: shell.p_shell, -11: shell.pf} |
67 |
67 |
global_stats = {"r":r, "R":R, "inner":shell.ps, "shell":shell.p_shell, "outer":shell.pf} |
global_stats = {"r":r, "R":R, "inner":shell.ps, "shell":shell.p_shell, "outer":shell.pf} |
68 |
68 |
return shell_estimation, global_stats |
return shell_estimation, global_stats |
69 |
69 |
|
|
70 |
70 |
def integrate(self, nis): |
def integrate(self, nis): |
71 |
71 |
#č no to teda disajn třidy je doopravdy hroznej |
#č no to teda disajn třidy je doopravdy hroznej |
72 |
72 |
# .get_shell_estimation() will calculate radiuses and will update shell |
# .get_shell_estimation() will calculate radiuses and will update shell |
73 |
|
shell_estimation, global_stats = self.get_shell_estimation() |
|
74 |
|
sample_G = self.shell.rvs(nis) |
|
|
73 |
|
ghull_estimation, global_stats = self.get_shell_estimation() |
|
74 |
|
nodes_G = self.shell.rvs(nis) |
75 |
75 |
mask = is_outside(self.convex_hull, sample_G) |
mask = is_outside(self.convex_hull, sample_G) |
76 |
76 |
#č nevím proč, ale kdysi mě to vyšlo rychlejc jak obyčejný součet |
#č nevím proč, ale kdysi mě to vyšlo rychlejc jak obyčejný součet |
77 |
77 |
nf = len(mask[mask]) |
nf = len(mask[mask]) |
78 |
78 |
ns = nis - nf |
ns = nis - nf |
79 |
|
p_shell = self.shell.p_shell |
|
|
79 |
|
# shell_estimation -22: inner, -3: shell, -11: outer |
|
80 |
|
p_shell = shell_estimation.pop(-3) |
80 |
81 |
shell_pf = nf/nis * p_shell |
shell_pf = nf/nis * p_shell |
81 |
82 |
shell_ps = ns/nis * p_shell |
shell_ps = ns/nis * p_shell |
82 |
83 |
|
|
83 |
|
global_stats[] |
|
84 |
|
# -1 = 'outside' |
|
85 |
|
# -2 = 'inside' |
|
86 |
|
nodes.event_id = mask - 2 |
|
87 |
|
nodes.is_outside = mask |
|
|
84 |
|
# ghull_estimation -22: inner, -21: shell inside, -12: shell outside, -11: outer |
|
85 |
|
ghull_estimation = shell_estimation; del(shell_estimation) |
|
86 |
|
ghull_estimation[-21] = shell_ps |
|
87 |
|
ghull_estimation[-12] = shell_pf |
|
88 |
|
global_stats["shell inside"] = shell_ps |
|
89 |
|
global_stats["shell outside"] = shell_pf |
|
90 |
|
|
|
91 |
|
# convex_hull_estimation -2: inside, -1: outside |
|
92 |
|
inside = shell_ps + self.shell.ps |
|
93 |
|
outside = shell_pf + self.shell.pf |
|
94 |
|
convex_hull_estimation = {-2: inside, -1: outside} |
|
95 |
|
global_stats["inside"] = inside |
|
96 |
|
global_stats["outside"] = outside |
|
97 |
|
|
|
98 |
|
nodes = self.sample.f_model.new_sample(nodes_G, space='G') |
|
99 |
|
# -2 = 'inside' -1 = 'outside' |
|
100 |
|
nodes = CandyBox(nodes, event_id=mask-2, is_outside=mask) |
|
101 |
|
|
|
102 |
|
return nodes, ghull_estimation, convex_hull_estimation, global_stats |
|
103 |
|
|
88 |
104 |
|
|
89 |
105 |
|
|
90 |
106 |
|
|