本文整理汇总了PHP中pts_math::standard_error方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_math::standard_error方法的具体用法?PHP pts_math::standard_error怎么用?PHP pts_math::standard_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_math
的用法示例。
在下文中一共展示了pts_math::standard_error方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderGraphLines
protected function renderGraphLines()
{
$prev_value = 0;
foreach ($this->test_result->test_result_buffer->buffer_items as &$buffer_item) {
$paint_color = $this->get_paint_color($buffer_item->get_result_identifier());
$result_array = $buffer_item->get_result_value();
$raw_array = $buffer_item->get_result_raw();
$point_counter = count($result_array);
$regression_plots = array();
$poly_points = array();
$g = $this->svg_dom->make_g(array('stroke' => $paint_color, 'stroke-width' => 1, 'fill' => $paint_color));
for ($i = 0; $i < $point_counter; $i++) {
$value = isset($result_array[$i]) ? $result_array[$i] : -1;
if ($value < 0) {
// Draw whatever is needed of the line so far, since there is no result here
$this->draw_graph_line_process($poly_points, $paint_color, $regression_plots, $point_counter, $g);
continue;
}
$identifier = $buffer_item->get_result_identifier();
$std_error = isset($raw_array[$i]) ? pts_math::standard_error(pts_strings::colon_explode($raw_array[$i])) : 0;
$data_string = $identifier . ': ' . $value;
$value_plot_top = $this->i['graph_top_end'] + 1 - ($this->i['graph_max_value'] == 0 ? 0 : round($value / $this->i['graph_max_value'] * ($this->i['graph_top_end'] - $this->i['top_start'])));
$px_from_left = round($this->i['left_start'] + $this->i['identifier_width'] * ($i + (count($this->graph_identifiers) > 1 ? 1 : 0)));
if ($px_from_left > $this->i['graph_left_end']) {
break;
}
if ($value_plot_top >= $this->i['graph_top_end']) {
$value_plot_top = $this->i['graph_top_end'] - 1;
}
array_push($poly_points, array($px_from_left, $value_plot_top, $data_string, $std_error));
if (isset($this->d['regression_marker_threshold']) && $this->d['regression_marker_threshold'] > 0 && $i > 0 && abs(1 - $value / $prev_value) > $this->d['regression_marker_threshold']) {
$regression_plots[$i - 1] = $prev_identifier . ': ' . $prev_value;
$regression_plots[$i] = $identifier . ': ' . $value;
}
$prev_identifier = $identifier;
$prev_value = $value;
}
$this->draw_graph_line_process($poly_points, $paint_color, $regression_plots, $point_counter, $g);
}
}
示例2: remove_noisy_results
public function remove_noisy_results($threshold = 0.6)
{
if ($this->test_profile->get_display_format() != 'BAR_GRAPH') {
return false;
}
$is_multi_way = pts_render::multi_way_identifier_check($this->test_result_buffer->get_identifiers());
$keys = array_keys($this->test_result_buffer->buffer_items);
if ($is_multi_way) {
$key_sets = array();
foreach ($keys as $k) {
$identifier_r = pts_strings::trim_explode(': ', $this->test_result_buffer->buffer_items[$k]->get_result_identifier());
if (!isset($key_sets[$identifier_r[0]])) {
$key_sets[$identifier_r[0]] = array();
}
$key_sets[$identifier_r[0]][] = $k;
}
} else {
$key_sets = array($keys);
}
foreach ($key_sets as $keys) {
$jiggy_results = 0;
foreach ($keys as $k) {
$raw = $this->test_result_buffer->buffer_items[$k]->get_result_raw();
if (!empty($raw)) {
$raw = pts_math::standard_error(pts_strings::colon_explode($raw));
if ($raw > 10) {
$jiggy_results++;
}
}
}
if ($jiggy_results / count($keys) > $threshold) {
foreach ($keys as $k) {
unset($this->test_result_buffer->buffer_items[$k]);
}
}
}
return true;
}
示例3: render_graph_bars
protected function render_graph_bars()
{
$bar_count = count($this->results);
$separator_height = ($a = 6 - floor($bar_count / 2) * 2) > 0 ? $a : 0;
$bar_height = floor(($this->i['identifier_height'] - ($this->is_multi_way_comparison ? 4 : 0) - $separator_height - $bar_count * $separator_height) / $bar_count);
$this->i['graph_max_value'] = $this->i['graph_max_value'] != 0 ? $this->i['graph_max_value'] : 1;
$work_area_width = $this->i['graph_left_end'] - $this->i['left_start'];
$group_offsets = array();
$id_offsets = array();
$g_bars = $this->svg_dom->make_g(array('stroke' => self::$c['color']['body_light'], 'stroke-width' => 1));
$g_se = $this->svg_dom->make_g(array('font-size' => $this->i['identifier_size'] - 2, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));
$g_values = $this->svg_dom->make_g(array('font-size' => $this->i['identifier_size'], 'fill' => self::$c['color']['body_text']));
$bar_x = $this->i['left_start'] + 0.5;
foreach ($this->results as $identifier => &$group) {
$paint_color = $this->get_paint_color($identifier);
foreach ($group as &$buffer_item) {
// if identifier is 0, not a multi-way comparison or anything special
if ($identifier == 0 && !$this->is_multi_way_comparison) {
// See if the result identifier matches something to be color-coded better
$result_identifier = strtolower($buffer_item->get_result_identifier());
if (strpos($result_identifier, 'geforce') !== false || strpos($result_identifier, 'nvidia') !== false) {
$paint_color = '#77b900';
} else {
if (strpos($result_identifier, 'radeon') !== false || strpos($result_identifier, 'amd ') !== false) {
$paint_color = '#f1052d';
} else {
if (strpos($result_identifier, 'intel ') !== false) {
$paint_color = '#0b5997';
}
}
}
}
$i_o = $this->calc_offset($group_offsets, $identifier);
$i = $this->calc_offset($id_offsets, $buffer_item->get_result_identifier());
$value = $buffer_item->get_result_value();
$graph_size = max(0, round($value / $this->i['graph_max_value'] * $work_area_width));
$value_end_right = max($this->i['left_start'] + $graph_size, 1);
$px_bound_top = $this->i['top_start'] + ($this->is_multi_way_comparison ? 5 : 0) + $this->i['identifier_height'] * $i + $bar_height * $i_o + $separator_height * ($i_o + 1);
$px_bound_bottom = $px_bound_top + $bar_height;
$middle_of_bar = $px_bound_top + $bar_height / 2 + ($this->i['identifier_size'] - 4);
$title_tooltip = $buffer_item->get_result_identifier() . ': ' . $value;
$std_error = -1;
if ($raw_values = $buffer_item->get_result_raw()) {
$std_error = pts_strings::colon_explode($raw_values);
switch (count($std_error)) {
case 0:
$std_error = -1;
break;
case 1:
$std_error = 0;
break;
default:
$std_error = pts_math::standard_error($std_error);
break;
}
}
$this->svg_dom->add_element('rect', array('x' => $bar_x, 'y' => $px_bound_top + 0.5, 'height' => $bar_height, 'width' => $graph_size, 'fill' => in_array($buffer_item->get_result_identifier(), $this->value_highlights) ? self::$c['color']['highlight'] : $paint_color, 'xlink:title' => $title_tooltip), $g_bars);
if ($std_error != -1 && $value != null) {
$std_error_height = 8;
if ($std_error > 0 && is_numeric($std_error)) {
$std_error_rel_size = round($std_error / $this->i['graph_max_value'] * ($this->i['graph_left_end'] - $this->i['left_start']));
if ($std_error_rel_size > 4) {
$std_error_base_left = $value_end_right - $std_error_rel_size + 0.5;
$std_error_base_right = $value_end_right + $std_error_rel_size + 0.5;
$this->svg_dom->draw_svg_line($std_error_base_left, $px_bound_top, $std_error_base_left, $px_bound_top + $std_error_height, self::$c['color']['notches'], 1);
$this->svg_dom->draw_svg_line($std_error_base_right, $px_bound_top, $std_error_base_right, $px_bound_top + $std_error_height, self::$c['color']['notches'], 1);
$this->svg_dom->draw_svg_line($std_error_base_left, $px_bound_top + 0.5, $std_error_base_right, $px_bound_top + 0.5, self::$c['color']['notches'], 1);
}
}
$bar_offset_34 = round($middle_of_bar + ($this->is_multi_way_comparison ? 0 : $bar_height / 5 + 1));
$this->svg_dom->add_text_element('SE +/- ' . pts_math::set_precision($std_error, 2), array('y' => $bar_offset_34, 'x' => $this->i['left_start'] - 5), $g_se);
}
if (self::text_string_width($value, $this->i['identifier_size']) + 2 < $graph_size) {
if (isset($this->d['identifier_notes'][$buffer_item->get_result_identifier()]) && $this->i['compact_result_view'] == false && !$this->is_multi_way_comparison) {
$note_size = self::$c['size']['key'] - 2;
$this->svg_dom->add_text_element($this->d['identifier_notes'][$buffer_item->get_result_identifier()], array('x' => $this->i['left_start'] + 4, 'y' => $px_bound_top + self::$c['size']['key'], 'font-size' => $note_size, 'fill' => self::$c['color']['body_text'], 'text-anchor' => 'start'));
}
$this->svg_dom->add_text_element($value, array('x' => $value_end_right - 5, 'y' => $middle_of_bar, 'text-anchor' => 'end'), $g_values);
} else {
if ($value > 0) {
// Write it in front of the result
$this->svg_dom->add_text_element($value, array('x' => $value_end_right + 6, 'y' => $middle_of_bar, 'fill' => self::$c['color']['text'], 'text-anchor' => 'start'), $g_values);
}
}
}
}
}
示例4: render_graph_bars
protected function render_graph_bars()
{
$bar_count = count($this->graph_data);
$separator_height = ($a = 6 - floor($bar_count / 2) * 2) > 0 ? $a : 0;
$multi_way = $this->is_multi_way_comparison && count($this->graph_data) > 1;
$bar_height = floor(($this->i['identifier_height'] - ($multi_way ? 4 : 0) - $separator_height - $bar_count * $separator_height) / $bar_count);
$this->i['graph_max_value'] = $this->i['graph_max_value'] != 0 ? $this->i['graph_max_value'] : 1;
$work_area_width = $this->i['graph_left_end'] - $this->i['left_start'];
for ($i_o = 0; $i_o < $bar_count; $i_o++) {
$paint_color = $this->get_paint_color(isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] : null);
foreach (array_keys($this->graph_data[$i_o]) as $i) {
$value = $this->graph_data[$i_o][$i];
$graph_size = max(0, round($value / $this->i['graph_max_value'] * $work_area_width));
$value_end_right = max($this->i['left_start'] + $graph_size, 1);
$px_bound_top = $this->i['top_start'] + ($multi_way ? 5 : 0) + $this->i['identifier_height'] * $i + $bar_height * $i_o + $separator_height * ($i_o + 1);
$px_bound_bottom = $px_bound_top + $bar_height;
$middle_of_bar = $px_bound_top + $bar_height / 2 + ($this->i['identifier_size'] - 4);
$title_tooltip = $this->graph_identifiers[$i] . ': ' . $value;
$std_error = -1;
if (isset($this->graph_data_raw[$i_o][$i])) {
$std_error = pts_strings::colon_explode($this->graph_data_raw[$i_o][$i]);
switch (count($std_error)) {
case 0:
$std_error = -1;
break;
case 1:
$std_error = 0;
break;
default:
$std_error = pts_math::standard_error($std_error);
break;
}
}
$this->svg_dom->add_element('rect', array('x' => $this->i['left_start'], 'y' => $px_bound_top, 'width' => $graph_size, 'height' => $bar_height, 'fill' => in_array($this->graph_identifiers[$i], $this->value_highlights) ? self::$c['color']['highlight'] : $paint_color, 'stroke' => self::$c['color']['body_light'], 'stroke-width' => 1, 'xlink:title' => $title_tooltip));
if ($std_error != -1 && $value != null) {
$std_error_height = 8;
if ($std_error > 0 && is_numeric($std_error)) {
$std_error_rel_size = round($std_error / $this->i['graph_max_value'] * ($this->i['graph_left_end'] - $this->i['left_start']));
if ($std_error_rel_size > 4) {
$this->svg_dom->draw_svg_line($value_end_right - $std_error_rel_size, $px_bound_top, $value_end_right - $std_error_rel_size, $px_bound_top + $std_error_height, self::$c['color']['notches'], 1);
$this->svg_dom->draw_svg_line($value_end_right + $std_error_rel_size, $px_bound_top, $value_end_right + $std_error_rel_size, $px_bound_top + $std_error_height, self::$c['color']['notches'], 1);
$this->svg_dom->draw_svg_line($value_end_right - $std_error_rel_size, $px_bound_top, $value_end_right + $std_error_rel_size, $px_bound_top, self::$c['color']['notches'], 1);
}
}
$bar_offset_34 = $middle_of_bar + ($multi_way ? 0 : $bar_height / 5 + 1);
$this->svg_dom->add_text_element('SE +/- ' . pts_math::set_precision($std_error, 2), array('x' => $this->i['left_start'] - 5, 'y' => $bar_offset_34, 'font-size' => $this->i['identifier_size'] - 2, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));
}
if ($this->text_string_width($value, $this->i['identifier_size']) + 2 < $graph_size) {
if (isset($this->d['identifier_notes'][$this->graph_identifiers[$i]]) && $this->i['compact_result_view'] == false) {
$note_size = self::$c['size']['key'] - 2;
$this->svg_dom->add_text_element($this->d['identifier_notes'][$this->graph_identifiers[$i]], array('x' => $this->i['left_start'] + 4, 'y' => $px_bound_top + self::$c['size']['key'], 'font-size' => $note_size, 'fill' => self::$c['color']['body_text'], 'text-anchor' => 'start'));
}
$this->svg_dom->add_text_element($value, array('x' => $value_end_right - 5, 'y' => $middle_of_bar, 'font-size' => $this->i['identifier_size'], 'fill' => self::$c['color']['body_text'], 'text-anchor' => 'end'));
} else {
if ($value > 0) {
// Write it in front of the result
$this->svg_dom->add_text_element($value, array('x' => $value_end_right + 6, 'y' => $middle_of_bar, 'font-size' => $this->i['identifier_size'], 'fill' => self::$c['color']['text'], 'text-anchor' => 'start'));
}
}
}
}
// write a new line along the bottom since the draw_rectangle_with_border above had written on top of it
$this->svg_dom->draw_svg_line($this->i['left_start'], $this->i['graph_top_end'], $this->i['graph_left_end'], $this->i['graph_top_end'], self::$c['color']['notches'], 1);
}
示例5: result_file_to_result_table
public static function result_file_to_result_table(&$result_file, &$system_id_keys = null, &$result_object_index = -1, &$flag_delta_results = false, $extra_attributes = null)
{
$result_table = array();
$result_tests = array();
$result_counter = 0;
foreach ($result_file->get_system_identifiers() as $sys_identifier) {
$result_table[$sys_identifier] = null;
}
foreach ($result_file->get_result_objects($result_object_index) as $ri => $result_object) {
if ($result_object->test_profile->get_identifier() == null) {
continue;
}
if ($extra_attributes != null) {
if (isset($extra_attributes['reverse_result_buffer'])) {
$result_object->test_result_buffer->buffer_values_reverse();
}
if (isset($extra_attributes['normalize_result_buffer'])) {
if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) {
$normalize_against = $extra_attributes['highlight_graph_values'][0];
} else {
$normalize_against = false;
}
$result_object->normalize_buffer_values($normalize_against);
}
}
if ($result_object_index != -1) {
if (is_array($result_object_index)) {
$result_tests[$result_counter] = new pts_graph_ir_value($result_object->get_arguments_description());
} else {
$result_tests[$result_counter] = new pts_graph_ir_value('Results');
}
} else {
$result_tests[$result_counter] = new pts_graph_ir_value($result_object->test_profile->get_title());
$result_tests[$result_counter]->set_attribute('title', $result_object->get_arguments_description());
if ($result_object->test_profile->get_identifier() != null) {
$result_tests[$result_counter]->set_attribute('href', 'http://openbenchmarking.org/test/' . $result_object->test_profile->get_identifier());
}
}
if ($result_object->test_profile->get_identifier() == null) {
if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') {
$result_tests[$result_counter]->set_attribute('alert', true);
foreach ($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item) {
$identifier = $buffer_item->get_result_identifier();
$value = $buffer_item->get_result_value();
$result_table[$identifier][$result_counter] = new pts_graph_ir_value($value, array('alert' => true));
}
$result_counter++;
}
continue;
}
switch ($result_object->test_profile->get_display_format()) {
case 'BAR_GRAPH':
$best_value = 0;
$worst_value = 0;
if (!defined('PHOROMATIC_TRACKER') && count($result_object->test_result_buffer->get_values()) > 1) {
switch ($result_object->test_profile->get_result_proportion()) {
case 'HIB':
$best_value = max($result_object->test_result_buffer->get_values());
$worst_value = min($result_object->test_result_buffer->get_values());
break;
case 'LIB':
$best_value = min($result_object->test_result_buffer->get_values());
$worst_value = max($result_object->test_result_buffer->get_values());
break;
}
}
$prev_value = 0;
$prev_identifier = null;
$prev_identifier_0 = null;
$values_in_buffer = $result_object->test_result_buffer->get_values();
sort($values_in_buffer);
$min_value_in_buffer = $values_in_buffer[0];
if ($min_value_in_buffer == 0) {
// Go through the values until something not 0, otherwise down in the code will be a divide by zero
for ($i = 1; $i < count($values_in_buffer) && $min_value_in_buffer == 0; $i++) {
$min_value_in_buffer = $values_in_buffer[$i];
}
}
$max_value_in_buffer = $values_in_buffer[count($values_in_buffer) - 1];
foreach ($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item) {
$identifier = $buffer_item->get_result_identifier();
$value = $buffer_item->get_result_value();
$raw_values = pts_strings::colon_explode($buffer_item->get_result_raw());
$percent_std = pts_math::set_precision(pts_math::percent_standard_deviation($raw_values), 2);
$std_error = pts_math::set_precision(pts_math::standard_error($raw_values), 2);
$delta = 0;
if (defined('PHOROMATIC_TRACKER')) {
$identifier_r = pts_strings::colon_explode($identifier);
if ($identifier_r[0] == $prev_identifier_0 && $prev_value != 0) {
$delta = pts_math::set_precision(abs(1 - $value / $prev_value), 4);
if ($delta > 0.02 && $delta > pts_math::standard_deviation($raw_values)) {
switch ($result_object->test_profile->get_result_proportion()) {
case 'HIB':
if ($value < $prev_value) {
$delta = 0 - $delta;
}
break;
case 'LIB':
if ($value > $prev_value) {
$delta = 0 - $delta;
//.........这里部分代码省略.........
示例6: renderGraphLines
protected function renderGraphLines()
{
$calculations_r = array();
$min_value = $this->graph_data[0][0];
$max_value = $this->graph_data[0][0];
$prev_value = $this->graph_data[0][0];
foreach (array_keys($this->graph_data) as $i_o) {
$paint_color = $this->get_special_paint_color(isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] : null);
$calculations_r[$paint_color] = array();
$point_counter = count($this->graph_data[$i_o]);
$regression_plots = array();
$poly_points = array();
for ($i = 0; $i < $point_counter; $i++) {
$value = $this->graph_data[$i_o][$i];
if ($value < 0 || $value == 0 && $this->graph_identifiers != null) {
// Draw whatever is needed of the line so far, since there is no result here
$this->draw_graph_line_process($poly_points, $paint_color, $regression_plots, $point_counter);
continue;
}
$identifier = isset($this->graph_identifiers[$i]) ? $this->graph_identifiers[$i] : null;
$std_error = isset($this->graph_data_raw[$i_o][$i]) ? pts_math::standard_error(pts_strings::colon_explode($this->graph_data_raw[$i_o][$i])) : 0;
$data_string = isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] . ($identifier ? ' @ ' . $identifier : null) . ': ' . $value : null;
$value_plot_top = $this->i['graph_top_end'] + 1 - ($this->i['graph_max_value'] == 0 ? 0 : round($value / $this->i['graph_max_value'] * ($this->i['graph_top_end'] - $this->i['top_start'])));
$px_from_left = round($this->i['left_start'] + $this->i['identifier_width'] * ($i + (count($this->graph_identifiers) > 1 ? 1 : 0)));
if ($value > $max_value) {
$max_value = $value;
} else {
if ($value < $min_value) {
$min_value = $value;
}
}
if ($px_from_left > $this->i['graph_left_end']) {
break;
}
if ($value_plot_top >= $this->i['graph_top_end']) {
$value_plot_top = $this->i['graph_top_end'] - 1;
}
array_push($poly_points, array($px_from_left, $value_plot_top, $data_string, $std_error));
if (isset($this->d['regression_marker_threshold']) && $this->d['regression_marker_threshold'] > 0 && $i > 0 && abs(1 - $value / $prev_value) > $this->d['regression_marker_threshold']) {
$regression_plots[$i - 1] = $prev_identifier . ': ' . $prev_value;
$regression_plots[$i] = $identifier . ': ' . $value;
}
array_push($calculations_r[$paint_color], $value);
$prev_identifier = $identifier;
$prev_value = $value;
}
$this->draw_graph_line_process($poly_points, $paint_color, $regression_plots, $point_counter);
}
}