当前位置: 首页>>代码示例>>PHP>>正文


PHP Basic::range方法代码示例

本文整理汇总了PHP中Basic::range方法的典型用法代码示例。如果您正苦于以下问题:PHP Basic::range方法的具体用法?PHP Basic::range怎么用?PHP Basic::range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Basic的用法示例。


在下文中一共展示了Basic::range方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: frequencyContinuous

 /**
  *  Given a dataset, the method calculates the absolute, relative and
  *  cumulative frequency of each generated class.
  *  
  *  @param array $data
  */
 public static function frequencyContinuous($data = [])
 {
     // Make sure that the elements are numeric
     array_map("self::isNumeric", $data);
     // Count the elements
     $items_count = self::countItems($data);
     // Get the number of classes
     $classes_num = self::getNumberOfClasses($items_count);
     // Get the bottom and top ranges
     $range_margins = Basic::range($data);
     $range = $range_margins->max - $range_margins->min;
     // Calculate the group size
     $group_size = self::calcGroupSize($range, $classes_num);
     // Create the classes
     $classes = self::createClasses($range_margins->min, $group_size, $classes_num);
     // Calculate the absolute, relative and cumulative frequency of each class
     $classes = self::calcFrequencyContinuous($data, $classes);
     // Return the classes
     return $classes;
 }
开发者ID:magaras,项目名称:pstats,代码行数:26,代码来源:Frequency.php

示例2: exponentialRegression

 /**
  * Create a function to calculate the exponential regression of a dataset.
  *
  * @param array $arrayY set of values.
  * @return array a function to accept X values and
  * return corresponding regression Y values and a coefficient of determination
  */
 public static function exponentialRegression($arrayY)
 {
     $arrayLength = count($arrayY);
     $arrayX = Basic::range(1, $arrayLength);
     $xSum = Basic::sum($arrayX);
     $yLog = array_map('log', $arrayY);
     $yLogSum = Basic::sum($yLog);
     $xSquaredSum = Basic::sum(array_map('NumbersPHP\\Basic::square', $arrayX));
     $xyLogSum = Basic::sum(array_map(create_function('$x, $yLog', 'return $x * $yLog;'), $arrayX, $yLog));
     $a = ($yLogSum * $xSquaredSum - $xSum * $xyLogSum) / ($arrayLength * $xSquaredSum - $xSum * $xSum);
     $b = ($arrayLength * $xyLogSum - $xSum * $yLogSum) / ($arrayLength * $xSquaredSum - $xSum * $xSum);
     $function = create_function('$x', 'if(is_array($x)) {' . 'foreach($x as &$value)' . '$value = exp(' . $a . ') * exp(' . $b . ' * $value);' . 'return $x;' . '}' . 'else ' . 'return exp(' . $a . ') * exp(' . $b . ' * $x);');
     return array($function, self::rSquared($arrayY, array_map($function, $arrayX)));
 }
开发者ID:dbirchak,项目名称:numbers.php,代码行数:21,代码来源:Statistic.php


注:本文中的Basic::range方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。