本文整理汇总了PHP中pts_math::find_percentile方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_math::find_percentile方法的具体用法?PHP pts_math::find_percentile怎么用?PHP pts_math::find_percentile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_math
的用法示例。
在下文中一共展示了pts_math::find_percentile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
foreach ($this->results as $identifier => &$group) {
$paint_color = $this->get_paint_color($identifier);
foreach ($group as &$buffer_item) {
$values = $buffer_item->get_result_value();
$values = explode(',', $values);
if (empty($values) || count($values) < 2) {
$values = $buffer_item->get_result_raw();
$values = explode(':', $values);
}
if (empty($values) || count($values) < 2) {
continue;
}
if (isset($values[10])) {
// Ignore any zeros at the start
if ($values[0] == 0 && $values[5] != 0) {
$j = 0;
while ($values[$j] == 0) {
unset($values[$j]);
$j++;
}
}
// Ignore any zeros at the end
if ($values[count($values) - 1] == 0 && $values[count($values) - 5] != 0) {
$j = count($values) - 1;
while ($values[$j] == 0) {
unset($values[$j]);
$j--;
}
}
}
$i_o = $this->calc_offset($group_offsets, $identifier);
$i = $this->calc_offset($id_offsets, $buffer_item->get_result_identifier());
$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;
$avg_value = round(array_sum($values) / count($values), 2);
$whisker_bottom = pts_math::find_percentile($values, 0.02);
$whisker_top = pts_math::find_percentile($values, 0.98);
$median = pts_math::find_percentile($values, 0.5);
$unique_values = array_unique($values);
$min_value = round(min($unique_values), 2);
$max_value = round(max($unique_values), 2);
$stat_value = 'Min: ' . $min_value . ' / Avg: ' . $avg_value . ' / Max: ' . $max_value;
$title_tooltip = $buffer_item->get_result_identifier() . ': ' . $stat_value;
$value_end_left = $this->i['left_start'] + max(1, round($whisker_bottom / $this->i['graph_max_value'] * $work_area_width));
$value_end_right = $this->i['left_start'] + round($whisker_top / $this->i['graph_max_value'] * $work_area_width);
$box_color = in_array($buffer_item->get_result_identifier(), $this->value_highlights) ? self::$c['color']['highlight'] : $paint_color;
$this->svg_dom->draw_svg_line($value_end_left, $middle_of_bar, $value_end_right, $middle_of_bar, $box_color, 2, array('xlink:title' => $title_tooltip));
$this->svg_dom->draw_svg_line($value_end_left, $px_bound_top, $value_end_left, $px_bound_bottom, self::$c['color']['notches'], 2, array('xlink:title' => $title_tooltip));
$this->svg_dom->draw_svg_line($value_end_right, $px_bound_top, $value_end_right, $px_bound_bottom, self::$c['color']['notches'], 2, array('xlink:title' => $title_tooltip));
$box_left = $this->i['left_start'] + round(pts_math::find_percentile($values, 0.25) / $this->i['graph_max_value'] * $work_area_width);
$box_middle = $this->i['left_start'] + round($median / $this->i['graph_max_value'] * $work_area_width);
$box_right = $this->i['left_start'] + round(pts_math::find_percentile($values, 0.75) / $this->i['graph_max_value'] * $work_area_width);
$this->svg_dom->add_element('rect', array('x' => $box_left, 'y' => $px_bound_top, 'width' => $box_right - $box_left, 'height' => $bar_height, 'fill' => $box_color, 'xlink:title' => $title_tooltip), $g_bars);
$this->svg_dom->draw_svg_line($box_middle, $px_bound_top, $box_middle, $px_bound_bottom, self::$c['color']['notches'], 2, array('xlink:title' => $title_tooltip));
$this->svg_dom->add_text_element($stat_value, array('x' => $this->i['left_start'] - 5, 'y' => ceil($px_bound_top + $bar_height * 0.8 + 6), 'font-size' => $this->i['identifier_size'] - 2, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));
foreach ($unique_values as &$val) {
if (($val < $whisker_bottom || $val > $whisker_top) && $val > 0.1) {
$this->svg_dom->draw_svg_circle($this->i['left_start'] + round($val / $this->i['graph_max_value'] * $work_area_width), $middle_of_bar, 1, self::$c['color']['notches']);
}
}
}
}
// 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);
}
示例2: render_graph_bars
protected function render_graph_bars()
{
$bar_count = count($this->graph_data);
$separator_height = ($a = 8 - 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);
$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) {
if (isset($this->graph_data[$i_o][$i][10])) {
// If there's 0 padding at start and/or end of test, might be from idling of test
if ($this->graph_data[$i_o][$i][0] == 0 && $this->graph_data[$i_o][$i][3] != 0) {
$j = 0;
while ($this->graph_data[$i_o][$i][$j] == 0) {
unset($this->graph_data[$i_o][$i][$j]);
$j++;
}
}
if ($this->graph_data[$i_o][$i][count($this->graph_data[$i_o][$i]) - 1] == 0 && $this->graph_data[$i_o][$i][count($this->graph_data[$i_o][$i]) - 4] != 0) {
$j = count($this->graph_data[$i_o][$i]) - 1;
while ($this->graph_data[$i_o][$i][$j] == 0) {
unset($this->graph_data[$i_o][$i][$j]);
$j--;
}
}
}
$avg_value = round(array_sum($this->graph_data[$i_o][$i]) / count($this->graph_data[$i_o][$i]), 2);
$whisker_bottom = pts_math::find_percentile($this->graph_data[$i_o][$i], 0.02);
$whisker_top = pts_math::find_percentile($this->graph_data[$i_o][$i], 0.98);
$median = pts_math::find_percentile($this->graph_data[$i_o][$i], 0.5);
$unique_values = array_unique($this->graph_data[$i_o][$i]);
$min_value = round(min($unique_values), 2);
$max_value = round(max($unique_values), 2);
$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;
$stat_value = 'Min: ' . $min_value . ' / Avg: ' . $avg_value . ' / Max: ' . $max_value;
$title_tooltip = $this->graph_identifiers[$i] . ': ' . $stat_value;
$value_end_left = $this->i['left_start'] + max(1, round($whisker_bottom / $this->i['graph_max_value'] * $work_area_width));
$value_end_right = $this->i['left_start'] + round($whisker_top / $this->i['graph_max_value'] * $work_area_width);
$box_color = in_array($this->graph_identifiers[$i], $this->value_highlights) ? self::$c['color']['highlight'] : $paint_color;
$this->svg_dom->draw_svg_line($value_end_left, $middle_of_bar, $value_end_right, $middle_of_bar, $box_color, 2, array('xlink:title' => $title_tooltip));
$this->svg_dom->draw_svg_line($value_end_left, $px_bound_top, $value_end_left, $px_bound_bottom, self::$c['color']['notches'], 2, array('xlink:title' => $title_tooltip));
$this->svg_dom->draw_svg_line($value_end_right, $px_bound_top, $value_end_right, $px_bound_bottom, self::$c['color']['notches'], 2, array('xlink:title' => $title_tooltip));
$box_left = $this->i['left_start'] + round(pts_math::find_percentile($this->graph_data[$i_o][$i], 0.25) / $this->i['graph_max_value'] * $work_area_width);
$box_middle = $this->i['left_start'] + round($median / $this->i['graph_max_value'] * $work_area_width);
$box_right = $this->i['left_start'] + round(pts_math::find_percentile($this->graph_data[$i_o][$i], 0.75) / $this->i['graph_max_value'] * $work_area_width);
$this->svg_dom->add_element('rect', array('x' => $box_left, 'y' => $px_bound_top, 'width' => $box_right - $box_left, 'height' => $bar_height, 'fill' => $box_color, 'stroke' => self::$c['color']['body_light'], 'stroke-width' => 1, 'xlink:title' => $title_tooltip));
$this->svg_dom->draw_svg_line($box_middle, $px_bound_top, $box_middle, $px_bound_bottom, self::$c['color']['notches'], 2, array('xlink:title' => $title_tooltip));
$this->svg_dom->add_text_element($stat_value, array('x' => $this->i['left_start'] - 5, 'y' => ceil($px_bound_top + $bar_height * 0.8 + 6), 'font-size' => $this->i['identifier_size'] - 2, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));
foreach ($unique_values as &$val) {
if (($val < $whisker_bottom || $val > $whisker_top) && $val > 0.1) {
$this->svg_dom->draw_svg_circle($this->i['left_start'] + round($val / $this->i['graph_max_value'] * $work_area_width), $middle_of_bar, 1, self::$c['color']['notches']);
}
}
}
}
// 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);
}