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


PHP exp函数代码示例

本文整理汇总了PHP中exp函数的典型用法代码示例。如果您正苦于以下问题:PHP exp函数的具体用法?PHP exp怎么用?PHP exp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: gaussianDensity

 /**
  * Guassian distribution density
  *
  * @param int $x        	
  * @return float
  */
 protected function gaussianDensity($x)
 {
     $y = -(1 / 2) * pow($x / $this->deviation, 2);
     $y = exp($y);
     $y = 1 / sqrt(2 * pi()) * $y;
     return $y;
 }
开发者ID:imonroe,项目名称:coldreader,代码行数:13,代码来源:GaussianComparator.php

示例2: inverse

 public function inverse($p)
 {
     $Y = $p->x - $this->x0;
     $X = $p->y - $this->y0;
     $rotI = $Y / $this->R;
     $rotB = 2 * (atan(exp(X / $this->R)) - Sourcemap_Proj::PI / 4.0);
     $b = asin(cos($this->b0) * sin($rotB) + sin($this->b0) * cos($rotB) * cos($rotI));
     $I = atan(sin($rotI) / (cos($this->b0) * cos($rotI) - sin($this->b0) * tan($rotB)));
     $lambda = $this->lambda0 + $I / $this->alpha;
     $S = 0.0;
     $phy = $b;
     $prevPhy = -1000.0;
     $iteration = 0;
     while (abs($phy - $prevPhy) > 1.0E-7) {
         if (++$iteration > 20) {
             throw new Exception("Infinity...");
         }
         //S = log(tan(Sourcemap_Proj::PI / 4.0 + $phy / 2.0));
         $S = 1.0 / $this->alpha * (log(tan(Sourcemap_Proj::PI / 4.0 + $b / 2.0)) - $this->K) + $this->e * log(tan(Sourcemap_Proj::PI / 4.0 + asin($this->e * sin($phy)) / 2.0));
         $prevPhy = $phy;
         $phy = 2.0 * atan(exp($S)) - Sourcemap_Proj::PI / 2.0;
     }
     $p->x = $lambda;
     $p->y = $phy;
     return $p;
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:26,代码来源:somerc.php

示例3: get_humidex

 /**
  * Computes the humidex index.
  *
  * @param   integer  $t      Temperature in celcius.
  * @param   integer  $dew    Dew point temperature in celcius.
  * @return  float   The computed humidex.
  *
  * @since    2.0.0
  */
 private function get_humidex($t, $dew)
 {
     $dew = $dew + 273.15;
     $e = 6.11 * exp(5417.753 * (1 / 273.16 - 1 / $dew));
     $result = $t + 0.5555 * ($e - 10);
     return round($result);
 }
开发者ID:Torchwood7,项目名称:torchwood-site,代码行数:16,代码来源:trait-weather-client.php

示例4: sa

function sa($members)
{
    $T = 100.0;
    $now_temp = 10000;
    $n = count($members);
    $status = 0;
    $best = 1000000000;
    while ($T > 0) {
        do {
            $t1 = rand(0, $n - 1);
            $t2 = rand(0, $n - 1);
        } while ($t1 == $t2);
        $now = sqr(abs($members[$t1]['chosen1'] - $t1)) + sqr(abs($members[$t2]['chosen1'] - $t2));
        $new = sqr(abs($members[$t1]['chosen1'] - $t2)) + sqr(abs($members[$t2]['chosen1'] - $t1));
        if ($new < $now || lcg_value() <= exp(($now - $new) / $T)) {
            $temp = $members[$t1];
            $members[$t1] = $members[$t2];
            $members[$t2] = $temp;
            $status += $new - $now;
            if ($status < $best) {
                $res = $members;
            }
        }
        $T -= 0.02;
    }
    return $res;
}
开发者ID:fei960922,项目名称:ACM_Website_2014_PHP,代码行数:27,代码来源:logistics_model.php

示例5: compute

 /**
  * @param float $a
  * @param float $b
  *
  * @return float
  */
 public function compute($a, $b)
 {
     $score = 2 * Product::scalar($a, $b);
     $squares = Product::scalar($a, $a) + Product::scalar($b, $b);
     $result = exp(-$this->gamma * ($squares - $score));
     return $result;
 }
开发者ID:php-ai,项目名称:php-ml,代码行数:13,代码来源:RBF.php

示例6: MetersToLatLon

 public function MetersToLatLon($mx, $my)
 {
     $lon = $mx / $this->originShift * 180.0;
     $lat = $my / $this->originShift * 180.0;
     $lat = 180 / pi() * (2 * atan(exp($lat * pi() / 180.0)) - pi() / 2.0);
     return array($lat, $lon);
 }
开发者ID:netconstructor,项目名称:cartodb-staticmap-php,代码行数:7,代码来源:class.cartodb-staticmap.php

示例7: PMF

 /**
  * Poisson distribution - probability mass function
  * A discrete probability distribution that expresses the probability of a given number of events
  * occurring in a fixed interval of time and/or space if these events occur with a known average
  * rate and independently of the time since the last event.
  * https://en.wikipedia.org/wiki/Poisson_distribution
  *
  *                              λᵏℯ^⁻λ
  * P(k events in an interval) = ------
  *                                k!
  *
  * @param  int   $k events in the interval
  * @param  float $λ average number of successful events per interval
  *
  * @return float The Poisson probability of observing k successful events in an interval
  */
 public static function PMF(int $k, float $λ) : float
 {
     Support::checkLimits(self::LIMITS, ['k' => $k, 'λ' => $λ]);
     $λᵏℯ^−λ = pow($λ, $k) * exp(-$λ);
     $k! = Combinatorics::factorial($k);
     return $λᵏℯ^−λ / $k!;
 }
开发者ID:markrogoyski,项目名称:math-php,代码行数:23,代码来源:Poisson.php

示例8: getIntersect

 public function getIntersect($dp = 0)
 {
     if ($dp != 0) {
         return round(exp($this->_intersect), $dp);
     }
     return exp($this->_intersect);
 }
开发者ID:Kiranj1992,项目名称:PHPExcel,代码行数:7,代码来源:exponentialBestFitClass.php

示例9: calculate

 /**
  * @throws RegressionException
  */
 public function calculate()
 {
     if ($this->sourceSequence === null) {
         throw new RegressionException('The input sequence is not set');
     }
     if (count($this->sourceSequence) < $this->dimension) {
         throw new RegressionException(sprintf('The dimension of the sequence of at least %s', $this->dimension));
     }
     foreach ($this->sourceSequence as $k => $v) {
         if ($v[1] !== null) {
             $this->sumIndex[0] += $v[0];
             $this->sumIndex[1] += $v[1];
             $this->sumIndex[2] += $v[0] * $v[0] * $v[1];
             $this->sumIndex[3] += $v[1] * log($v[1]);
             $this->sumIndex[4] += $v[0] * $v[1] * log($v[1]);
             $this->sumIndex[5] += $v[0] * $v[1];
         }
     }
     $denominator = $this->sumIndex[1] * $this->sumIndex[2] - $this->sumIndex[5] * $this->sumIndex[5];
     $A = exp(($this->sumIndex[2] * $this->sumIndex[3] - $this->sumIndex[5] * $this->sumIndex[4]) / $denominator);
     $B = ($this->sumIndex[1] * $this->sumIndex[4] - $this->sumIndex[5] * $this->sumIndex[3]) / $denominator;
     foreach ($this->sourceSequence as $i => $val) {
         $coordinate = [$val[0], $A * exp($B * $val[0])];
         $this->resultSequence[] = $coordinate;
     }
     $this->equation = sprintf('y = %s+ e^(%sx)', round($A, 2), round($B, 2));
     $this->push();
 }
开发者ID:robotomize,项目名称:regression-php,代码行数:31,代码来源:ExponentialRegression.php

示例10: relh

function relh($tmpc, $dwpc)
{
    $e = 6.112 * exp(17.67 * (double) $dwpc / ((double) $dwpc + 243.5));
    $es = 6.112 * exp(17.67 * (double) $tmpc / ((double) $tmpc + 243.5));
    $relh = $e / $es * 100.0;
    return round($relh, 0);
}
开发者ID:muthulatha,项目名称:iem,代码行数:7,代码来源:mlib.php

示例11: metersToLatLon

 static function metersToLatLon($mx, $my)
 {
     $lng = $mx / self::originShift() * 180.0;
     $lat = $my / self::originShift() * 180.0;
     $lat = 180 / pi() * (2 * atan(exp($lat * pi() / 180.0)) - pi() / 2.0);
     return new GoogleMapPoint($lat, $lng);
 }
开发者ID:markguinn,项目名称:silverstripe-gis,代码行数:7,代码来源:GoogleMapUtility.php

示例12: classify

 public function classify($string)
 {
     if ($this->total_samples === 0) {
         return array();
     }
     $tokens = $this->tokenizer->tokenize($string);
     $total_score = 0;
     $scores = array();
     foreach ($this->subjects as $subject => $subject_data) {
         $subject_data['prior_value'] = log($subject_data['count_samples'] / $this->total_samples);
         $this->subjects[$subject] = $subject_data;
         $scores[$subject] = 0;
         foreach ($tokens as $token) {
             $count = isset($this->tokens[$token][$subject]) ? $this->tokens[$token][$subject] : 0;
             $scores[$subject] += log(($count + 1) / ($subject_data['count_tokens'] + $this->total_tokens));
         }
         $scores[$subject] = $subject_data['prior_value'] + $scores[$subject];
         $total_score += $scores[$subject];
     }
     $min = min($scores);
     $sum = 0;
     foreach ($scores as $subject => $score) {
         $scores[$subject] = exp($score - $min);
         $sum += $scores[$subject];
     }
     $total = 1 / $sum;
     foreach ($scores as $subject => $score) {
         $scores[$subject] = $score * $total;
     }
     arsort($scores);
     $max = max($scores);
     $maxs = array_search(max($scores), $scores);
     return $maxs;
 }
开发者ID:nhunght,项目名称:mork_SmartOSC,代码行数:34,代码来源:Classifier.php

示例13: evaluate

 public function evaluate()
 {
     if (is_array($result = parent::evaluate())) {
         throw new ParsingException('exp accept only one argument');
     }
     return (double) exp($result);
 }
开发者ID:thesoftwarefarm,项目名称:exprlib,代码行数:7,代码来源:Exp.php

示例14: calculate

 /**
  * @throws RegressionException
  */
 public function calculate()
 {
     if ($this->sourceSequence === null) {
         throw new RegressionException('The input sequence is not set');
     }
     if (count($this->sourceSequence) < $this->dimension) {
         throw new RegressionException(sprintf('The dimension of the sequence of at least %s', $this->dimension));
     }
     $k = 0;
     foreach ($this->sourceSequence as $k => $v) {
         if ($v[1] !== null) {
             $this->sumIndex[0] += log($v[0]);
             $this->sumIndex[1] += log($v[0]) * log($v[1]);
             $this->sumIndex[2] += log($v[1]);
             $this->sumIndex[3] += pow(log($v[0]), 2);
         }
     }
     $k += 1;
     $B = ($k * $this->sumIndex[1] - $this->sumIndex[2] * $this->sumIndex[0]) / ($k * $this->sumIndex[3] - $this->sumIndex[0] * $this->sumIndex[0]);
     $A = exp(($this->sumIndex[2] - $B * $this->sumIndex[0]) / $k);
     foreach ($this->sourceSequence as $i => $val) {
         $coordinate = [$val[0], $A * pow($val[0], $B)];
         $this->resultSequence[] = $coordinate;
     }
     $this->equation = sprintf('y = %s + x^%s', round($A, 2), round($B, 2));
     $this->push();
 }
开发者ID:robotomize,项目名称:regression-php,代码行数:30,代码来源:PowerRegression.php

示例15: pValue

 /**
  * @param array $data
  *
  * @return int|void
  */
 public function pValue(array $data)
 {
     $n = count($data);
     if ($n < 5) {
         throw new TooLessDataException();
     }
     $data = $this->normalize($data);
     sort($data, SORT_NUMERIC);
     $nd = new NormalDistribution();
     $s = 0.0;
     foreach ($data as $i => $v) {
         $cdf = $nd->normalCdf($v);
         $i++;
         $s += (2.0 * $i - 1.0) * log($cdf) + (2 * ($n - $i) + 1) * log(1 - $cdf);
     }
     $a2 = -$n - 1 / $n * $s;
     $a2 = $a2 * (1 + 0.75 / $n + 2.25 / pow($n, 2));
     if ($a2 >= 0.6) {
         return exp(1.2937 - 5.709 * $a2 + 0.0186 * pow($a2, 2));
     }
     if (0.34 < $a2 and $a2 < 0.6) {
         return exp(0.9177 - 4.279 * $a2 - 1.38 * pow($a2, 2));
     }
     if (0.2 < $a2 and $a2 < 0.34) {
         return 1 - exp(-8.318 + 42.796 * $a2 - 59.938 * pow($a2, 2));
     }
     if ($a2 <= 0.2) {
         return 1 - exp(-13.436 + 101.14 * $a2 - 223.73 * pow($a2, 2));
     }
 }
开发者ID:ghua,项目名称:AndersonDarlingTest,代码行数:35,代码来源:AndersonDarlingTest.php


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