File estimation.py changed (mode: 100644) (index b383753..dc60aa7) |
... |
... |
def Voronoi_2_point_estimation(sample_box, model_space='Rn', sampling_space=None |
316 |
316 |
if gradient is None: |
if gradient is None: |
317 |
317 |
# indexy ii nás moc nezajimajou |
# indexy ii nás moc nezajimajou |
318 |
318 |
# vzdalenosti snad byjsme zvladli použit? |
# vzdalenosti snad byjsme zvladli použit? |
|
319 |
|
# dd1 jsou vzdalenosti tečiček do centra Voroneho buňky |
319 |
320 |
dd1 = dd[Vor_mask] |
dd1 = dd[Vor_mask] |
320 |
321 |
|
|
321 |
322 |
dd2, ii2 = tree.query(h_plan_model_ma, k=[2], p=p_norm) |
dd2, ii2 = tree.query(h_plan_model_ma, k=[2], p=p_norm) |
|
... |
... |
def Voronoi_2_point_estimation(sample_box, model_space='Rn', sampling_space=None |
324 |
325 |
|
|
325 |
326 |
# tahle hračka s indexy je pro numpy poměrně drahá |
# tahle hračka s indexy je pro numpy poměrně drahá |
326 |
327 |
failsii_2 = failsi[ii2] |
failsii_2 = failsi[ii2] |
327 |
|
|
|
328 |
328 |
# jeden vzorek (včetně hustoty PDF[i]) je nám vždy znám |
# jeden vzorek (včetně hustoty PDF[i]) je nám vždy znám |
329 |
329 |
# porucha |
# porucha |
330 |
330 |
if failsi[i]: |
if failsi[i]: |
331 |
331 |
points_1 = PDF[i] * dd2 |
points_1 = PDF[i] * dd2 |
332 |
332 |
node_pf_estimations = points_1 / (points_1 + PDF[ii2] * dd1) |
node_pf_estimations = points_1 / (points_1 + PDF[ii2] * dd1) |
|
333 |
|
node_pf_estimations = np.where(failsii_2,1, node_pf_estimations) |
333 |
334 |
node_pf_pure_estimations = dd2 / (dd1 + dd2) |
node_pf_pure_estimations = dd2 / (dd1 + dd2) |
|
335 |
|
node_pf_pure_estimations = np.where(failsii_2,1, node_pf_pure_estimations) |
334 |
336 |
|
|
335 |
337 |
cell_stats['Voronoi_2_point_upper_bound'] = cell_stats['cell_probability'] |
cell_stats['Voronoi_2_point_upper_bound'] = cell_stats['cell_probability'] |
336 |
|
cell_stats['Voronoi_2_point_failure_rate'] = np.sum(weights_sim*np.where(failsii_2,1, node_pf_estimations)) / nis |
|
337 |
|
cell_stats['Voronoi_2_point_pure_failure_rate'] = np.sum(weights_sim*np.where(failsii_2,1, node_pf_pure_estimations)) / nis |
|
|
338 |
|
cell_stats['Voronoi_2_point_failure_rate'] = np.sum(weights_sim * node_pf_estimations) / nis |
|
339 |
|
cell_stats['Voronoi_2_point_pure_failure_rate'] = np.sum(weights_sim * node_pf_pure_estimations) / nis |
338 |
340 |
cell_stats['Voronoi_2_point_lower_bound'] = np.sum(weights_sim[failsii_2]) / nis |
cell_stats['Voronoi_2_point_lower_bound'] = np.sum(weights_sim[failsii_2]) / nis |
339 |
341 |
cell_stats['Voronoi_failure_rate'] = cell_stats['cell_probability'] |
cell_stats['Voronoi_failure_rate'] = cell_stats['cell_probability'] |
340 |
|
nodes=CandyBox(h_plan[Vor_mask], w=h_plan.w[Vor_mask], node_pf_estimations=node_pf_estimations,\ |
|
|
342 |
|
nodes=CandyBox(h_plan.sampling_plan[Vor_mask], w=h_plan.w[Vor_mask], node_pf_estimations=node_pf_estimations,\ |
341 |
343 |
node_pf_pure_estimations=node_pf_pure_estimations) |
node_pf_pure_estimations=node_pf_pure_estimations) |
342 |
344 |
|
|
343 |
345 |
# neporucha |
# neporucha |
|
... |
... |
def Voronoi_2_point_estimation(sample_box, model_space='Rn', sampling_space=None |
355 |
357 |
cell_stats['Voronoi_2_point_pure_failure_rate'] = np.sum(weights_sim[failsii_2] * node_pf_pure_estimations) / nis |
cell_stats['Voronoi_2_point_pure_failure_rate'] = np.sum(weights_sim[failsii_2] * node_pf_pure_estimations) / nis |
356 |
358 |
cell_stats['Voronoi_2_point_lower_bound'] = 0 |
cell_stats['Voronoi_2_point_lower_bound'] = 0 |
357 |
359 |
cell_stats['Voronoi_failure_rate'] = 0 |
cell_stats['Voronoi_failure_rate'] = 0 |
358 |
|
nodes=CandyBox(h_plan[Vor_mask][failsii_2], w=weights_sim[failsii_2], node_pf_estimations=node_pf_estimations,\ |
|
|
360 |
|
nodes=CandyBox(h_plan.sampling_plan[Vor_mask][failsii_2], w=weights_sim[failsii_2], node_pf_estimations=node_pf_estimations,\ |
359 |
361 |
node_pf_pure_estimations=node_pf_pure_estimations) |
node_pf_pure_estimations=node_pf_pure_estimations) |
360 |
362 |
|
|
361 |
363 |
# take something with corresponding length |
# take something with corresponding length |
362 |
364 |
zeros = np.zeros(len(weights_sim) - len(dd2)) |
zeros = np.zeros(len(weights_sim) - len(dd2)) |
363 |
365 |
# add remaining nodes |
# add remaining nodes |
364 |
|
nodes.add_sample(CandyBox(h_plan[Vor_mask][~failsii_2], w=weights_sim[~failsii_2], node_pf_estimations=zeros,\ |
|
|
366 |
|
nodes.add_sample(CandyBox(h_plan.sampling_plan[Vor_mask][~failsii_2], w=weights_sim[~failsii_2], node_pf_estimations=zeros,\ |
365 |
367 |
node_pf_pure_estimations=zeros)) |
node_pf_pure_estimations=zeros)) |
366 |
368 |
|
|
367 |
369 |
|
|
|
... |
... |
def Voronoi_2_point_estimation(sample_box, model_space='Rn', sampling_space=None |
415 |
417 |
cell_stats['Voronoi_2_point_lower_bound'] = np.sum(h_plan.w[Vor_mask]*np.floor(node_pf_estimations)) / nis |
cell_stats['Voronoi_2_point_lower_bound'] = np.sum(h_plan.w[Vor_mask]*np.floor(node_pf_estimations)) / nis |
416 |
418 |
cell_stats['Voronoi_failure_rate'] = np.sum(h_plan.w[Vor_mask]*node_failsi) / nis |
cell_stats['Voronoi_failure_rate'] = np.sum(h_plan.w[Vor_mask]*node_failsi) / nis |
417 |
419 |
|
|
418 |
|
nodes=CandyBox(h_plan[Vor_mask], w=h_plan.w[Vor_mask], node_pf_estimations=node_pf_estimations,\ |
|
|
420 |
|
nodes=CandyBox(h_plan.sampling_plan[Vor_mask], w=h_plan.w[Vor_mask], node_pf_estimations=node_pf_estimations,\ |
419 |
421 |
node_pf_pure_estimations=node_pf_pure_estimations, node_failsi=node_failsi) |
node_pf_pure_estimations=node_pf_pure_estimations, node_failsi=node_failsi) |
420 |
422 |
|
|
421 |
423 |
|
|