* include/functions_forecast.php: Fixed division by zero.

* operation/visual_console/public_console.php: Fixed link
	to public visual console.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9992 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
vgilc 2014-05-23 06:44:15 +00:00
parent 8661765df1
commit 091db5c2ef
3 changed files with 35 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2014-05-23 Vanessa Gil <vanessa.gil@artica.es>
* include/functions_forecast.php: Fixed division by zero.
* operation/visual_console/public_console.php: Fixed link
to public visual console.
2014-05-22 Sergio Martin <sergio.martin@artica.es> 2014-05-22 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php: Fix end of unknown * include/functions_graph.php: Fix end of unknown

View File

@ -116,18 +116,31 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
// 3.2 Standard deviation for Y: sqrt((Sum(Yi²)/Obs) - (avg Y)²) // 3.2 Standard deviation for Y: sqrt((Sum(Yi²)/Obs) - (avg Y)²)
// Linear correlation coefficient: // Linear correlation coefficient:
$avg_x = $cont/$sum_xi; if ($sum_xi != 0) {
$avg_x = $cont/$sum_xi;
} else {
$avg_x = 0;
}
if ($sum_yi != 0) if ($sum_yi != 0)
$avg_y = $cont/$sum_yi; $avg_y = $cont/$sum_yi;
else else
$avg_y = 0; $avg_y = 0;
$covariance = $sum_xi_yi/$cont;
$dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x)); /*
$dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y)); if ($cont != 0) {
$covariance = $sum_xi_yi/$cont;
$dev_x = sqrt(($sum_xi2/$cont) - ($avg_x*$avg_x));
$dev_y = sqrt(($sum_yi2/$cont) - ($avg_y*$avg_y));
} else {
$covariance = 0;
$dev_x = 0;
$dev_y = 0;
}
// Prevents division by zero // Prevents division by zero
if ($dev_x != 0 and $dev_y != 0) { if ($dev_x != 0 and $dev_y != 0) {
$linear_coef = $covariance / ($dev_x * $dev_y); $linear_coef = $covariance / ($dev_x * $dev_y);
} }
*/
// Agent interval could be zero, 300 is the predefined // Agent interval could be zero, 300 is the predefined
if ($sum_obs == 0) { if ($sum_obs == 0) {
$agent_interval = SECONDS_5MINUTES; $agent_interval = SECONDS_5MINUTES;
@ -159,7 +172,12 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$b = $b_num / $b_den; $b = $b_num / $b_den;
$a_num = ($sum_yi) - ($b * $sum_xi); $a_num = ($sum_yi) - ($b * $sum_xi);
$a = $a_num / $cont;
if ($cont != 0) {
$a = $a_num / $cont;
} else {
$a = 0;
}
// Data inicialization // Data inicialization
$output_data = array(); $output_data = array();

View File

@ -134,7 +134,10 @@ $(document).ready (function () {
description: '<?php echo __('Until refresh'); ?>', description: '<?php echo __('Until refresh'); ?>',
onExpiry: function () { onExpiry: function () {
href = "<?php echo ui_get_full_url();?>"; href = "<?php echo ui_get_full_url();?>";
href = href + "&refr=<?php echo $refr;?>"; $exists_refr = href.indexOf("refr");
if ($exists_refr == -1) {
href = href + "&refr=<?php echo $refr;?>";
}
$(document).attr ("location", href); $(document).attr ("location", href);
} }
} }
@ -146,4 +149,4 @@ $(document).ready (function () {
draw_lines (lines, 'layout_map'); draw_lines (lines, 'layout_map');
}); });
/* ]]> */ /* ]]> */
</script> </script>