• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP exp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: expm1

function expm1($x) {
    if (abs($x) < 1e-5) {
        return $x + 0.5*$x*$x;
    } else {
        return exp($x) - 1.0;
    }
}
开发者ID:holdenk,项目名称:picomath,代码行数:7,代码来源:expm1.php


示例17: prepareFprime

 /**
  * Compute the denominators which is the predicted expectation of
  * each feature given a set of weights L and a set of features for
  * each document for each class.
  * 
  * @param $feature_array All the data known about the training set
  * @param $l The current set of weights to be initialized
  * @return void
  */
 protected function prepareFprime(array &$feature_array, array &$l)
 {
     $this->denominators = array();
     foreach ($feature_array as $offset => $doc) {
         $numerator = array_fill_keys(array_keys($doc), 0.0);
         $denominator = 0.0;
         foreach ($doc as $cl => $f) {
             if (!is_array($f)) {
                 continue;
             }
             $tmp = 0.0;
             foreach ($f as $i) {
                 $tmp += $l[$i];
             }
             $tmp = exp($tmp);
             $numerator[$cl] += $tmp;
             $denominator += $tmp;
         }
         foreach ($doc as $class => $features) {
             if (!is_array($features)) {
                 continue;
             }
             foreach ($features as $fi) {
                 if (!isset($this->denominators[$fi])) {
                     $this->denominators[$fi] = 0;
                 }
                 $this->denominators[$fi] += $numerator[$class] / $denominator;
             }
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:40,代码来源:maxent_grad_descent.php


示例18: __construct

 public function __construct($ltDays = 42, $stDays = 7)
 {
     $this->ltDays = $ltDays;
     $this->stDays = $stDays;
     $this->ltExp = exp(-1 / $this->ltDays);
     $this->stExp = exp(-1 / $this->stDays);
 }
开发者ID:noginn,项目名称:endurance,代码行数:7,代码来源:StressCalculator.php


示例19: key

 public function key($key)
 {
     if ($this->numeric($key)) {
         $this->pushValue(floatval($key));
     } else {
         if ($key == "+") {
             $this->pushValue($this->pop() + $this->pop());
         } else {
             if ($key == "-") {
                 $t = $this->pop();
                 $this->push($this->pop() - $t);
             } else {
                 if ($key == "*") {
                     $this->pushValue($this->pop() * $this->pop());
                 } else {
                     if ($key == "enter") {
                         $this->push();
                     } else {
                         if ($key == "clx") {
                             $this->r[0] = 0;
                         } else {
                             if ($key == "/") {
                                 $t = $this->pop();
                                 if ($t != 0) {
                                     $this->pushValue($this->pop() / $t);
                                 }
                             } else {
                                 if ($key == "x^y") {
                                     $this->pushValue(exp(log($this->pop()) * $this->pop()));
                                 } else {
                                     if ($key == "clr") {
                                         $this->r[0] = 0;
                                         $this->r[1] = 0;
                                         $this->r[2] = 0;
                                         $this->r[3] = 0;
                                     } else {
                                         if ($key == "chs") {
                                             $this->r[0] = -$this->r[0];
                                         } else {
                                             if ($key == "sin") {
                                                 $this->pushValue(sin(deg2rad($this->pop())));
                                             } else {
                                                 if ($key == "chs") {
                                                     $this->r[0] = -$this->r[0];
                                                 } else {
                                                     throw new Exception("can't do key: " . $key);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:phpfit-svn,代码行数:59,代码来源:Calculator.php


示例20: cmpByRatingLeech

function cmpByRatingLeech(&$a, &$b)
{
    $aPeer = max($a["totalLeech"] + $a["totalSeed"], $a['sum_peers']);
    $bPeer = max($b["totalLeech"] + $b["totalSeed"], $b['sum_peers']);
    $a['sortVal'] = exp(-$aPeer / 5000.0) * exp($a['kinopoiskRating']);
    $b['sortVal'] = exp(-$bPeer / 5000.0) * exp($b['kinopoiskRating']);
    return $a["sortVal"] < $b["sortVal"];
}
开发者ID:filaPro,项目名称:torrent-parser,代码行数:8,代码来源:sorts.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP expandHomeDirectory函数代码示例发布时间:2022-05-15
下一篇:
PHP exit_with_success函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap