當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。