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


PHP tanh函数代码示例

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


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

示例1: calculate

 public function calculate($data)
 {
     $this->data = $data;
     $result = tanh($this->sum() * $this->beta * $this->betaWeight);
     //        $result = tanh($this->sum() * $this->beta * $this->betaWeight);
     return $result;
 }
开发者ID:Harry27PL,项目名称:si,代码行数:7,代码来源:NeuronSigmoidal.php

示例2: nicko

 function nicko(&$irc, &$data)
 {
     $args = array_slice($data->messageex, 1);
     $nick = $args[0];
     if (strlen($nick) > 0) {
         $this->score = $shifts = 0;
         $special_cost = array('69' => 500, 'dea?th' => 500, 'dark' => 400, 'n[i1]ght' => 300, 'n[i1]te' => 500, 'fuck' => 500, 'sh[i1]t' => 500, 'coo[l1]' => 500, 'kew[l1]' => 500, 'lame' => 500, 'dood' => 500, 'dude' => 500, '[l1](oo?|u)[sz]er' => 500, '[l1]eet' => 500, 'e[l1]ite' => 500, '[l1]ord' => 500, 'pron' => 1000, 'warez' => 1000, 'xx' => 100, '\\[rkx]0' => 1000, '\\0[rkx]' => 1000);
         foreach ($special_cost as $special => $cost) {
             $special_pattern = $special;
             if (ereg($special, $nick)) {
                 $this->punish($cost, "special");
             }
         }
         $clean = eregi_replace("[^A-Z0-9]", "", $nick);
         $this->punish(pow(10, strlen($nick) - strlen($clean)) - 1, "non-alha ({$clean} vs {$nick})");
         $k3wlt0k_weights = array(5, 5, 2, 5, 2, 3, 1, 2, 2, 2);
         for ($digit = 0; $digit < 10; $digit++) {
             $this->punish($k3wlt0k_weights[$digit] * substr_count($nick, $digit), "leet digits");
         }
         $this->punish($this->slow_pow(9, similar_text($nick, strtoupper($nick))) - 1, "lowercase");
         if (ereg("^.*[XZ]\$", $nick)) {
             $this->punish(50, "lame endings");
         }
         if (eregi("[0-9][a-z]", $nick, $regs)) {
             $shifts = @sizeof($regs) - 1;
             unset($regs);
         }
         if (eregi("[a-z][0-9]", $nick, $regs)) {
             $shifts = @sizeof($regs) - 1;
             unset($regs);
         }
         $this->punish($this->slow_pow(9, $shifts) - 1, "shifts");
         if (ereg("[A-Z]", $nick, $regs)) {
             $caps = @sizeof($regs) - 1;
             unset($regs);
             $this->punish($this->slow_pow(7, $caps), "upper case");
         }
         $percentage = 100 * (1 + tanh(($this->score - 400) / 400)) * (1 - 1 / (1 + $this->score / 5)) / 2;
         $digits = 2 * (2 - floor(log(100 - $percentage) / log(10)));
         $out = "'{$nick}' is " . sprintf("%." . $digits . "f", $percentage) . "% lame";
     } else {
         $out = "'" . $data['nick'] . "' is 100% lame";
     }
     $this->talk($irc, $data, $out);
     $this->log($irc, $data, $out);
 }
开发者ID:BackupTheBerlios,项目名称:lulubot,代码行数:46,代码来源:nickometer.php

示例3: activation

 function activation()
 {
     //calculate the outputs of the hidden neurons, the hidden neurons are tanh
     for ($i = 0; $i < $this->numHidden; $i++) {
         $hidVal =& $this->hiddenVal[$i];
         $hidVal = 0.0;
         for ($j = 0; $j < $this->numInputs; $j++) {
             $hidVal = $hidVal + $this->trainInput[$this->patNum][$j] * $this->weightsIH[$j][$i];
         }
         $hidVal = tanh($hidVal);
     }
     //calculate the output of the network, the output neuron is linear
     $this->outPred = 0.0;
     for ($i = 0; $i < $this->numHidden; $i++) {
         $this->outPred = $this->outPred + $this->hiddenVal[$i] * $this->weightsHO[$i];
     }
     //calculate the error
     $this->errThisPat = $this->outPred - $this->trainOutput[$this->patNum];
 }
开发者ID:0-php,项目名称:AI,代码行数:19,代码来源:multilayerperceptron.class.php

示例4: tanh

 /**
  * Returns the hyperbolic tangent of an angle.
  *
  * @param  number $angle
  * @return number
  */
 public function tanh($angle)
 {
     return tanh($angle);
 }
开发者ID:krishnaguragain,项目名称:math,代码行数:10,代码来源:MathExecutionEngine.php

示例5: tanh

 /**
  * Hyperbolic tangent.
  * @link http://php.net/manual/en/function.tanh.php
  * @param float $number <p>The argument to process</p>
  * @return float The hyperbolic tangent of <i>number</i>
  */
 public static function tanh($number)
 {
     return tanh($number);
 }
开发者ID:charlanalves,项目名称:sped,代码行数:10,代码来源:Math.php

示例6: tanh

 /**
  * @param float $x A number
  * @return float The hyperbolic tangent of the given value
  */
 public function tanh($x)
 {
     return tanh($x);
 }
开发者ID:neos,项目名称:flow-development-collection,代码行数:8,代码来源:MathHelper.php

示例7: define

<?php

define("MAX_64Bit", 9223372036854775807);
define("MAX_32Bit", 2147483647);
define("MIN_64Bit", -9223372036854775807 - 1);
define("MIN_32Bit", -2147483647 - 1);
$longVals = array(MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, MAX_32Bit * 2 + 1, MAX_32Bit * 2 - 1, MAX_64Bit - 1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1);
foreach ($longVals as $longVal) {
    echo "--- testing: {$longVal} ---\n";
    var_dump(tanh($longVal));
}
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:13,代码来源:tanh_basiclong_64bit.php

示例8: rtrim

echo rtrim("\t\tThese are a few words :) ... ");
echo rtrim("\t\tThese are a few words :) ... ", " \t.");
echo rtrim("\tExample string\n", "..");
echo chop("\t\tThese are a few words :) ... ");
echo chop("\t\tThese are a few words :) ... ", " \t.");
echo chop("\tExample string\n", "..");
echo acos(0.5);
echo acosh(0.5);
echo asin(0.5);
echo asinh(0.5);
echo atan(0.5);
echo atan2(0.5, 0.5);
echo atanh(0.5);
echo cos(0.5);
echo cosh(0.5);
echo sin(0.5);
echo sinh(0.5);
echo tan(0.5);
echo tanh(0.5);
echo exp(5.7);
echo exp(12);
echo log10(12);
echo log(12);
echo sqrt(2);
echo ceil(7.9);
echo floor(7.9);
echo fmod(5.7, 1.3);
echo ip2long("127.0.0.1");
echo long2ip(pow(2, 32) + 1024);
echo rad2deg(M_PI_4);
echo deg2rad(45);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:1596.php

示例9: tanh

 public static function tanh($self, $a)
 {
     return tanh($a);
 }
开发者ID:r3sist,项目名称:MathScript,代码行数:4,代码来源:mathscript.class.php

示例10: getCompatibilityByWeight

 /**
  * 
  * Get the compatibility by weight. Based on euclidean distance ...
  * @param array $searchee 
  * @param array $candidate
  * @param int $type
  */
 function getCompatibilityByWeight($searchee = array(), $candidate = array(), $type = 1)
 {
     $commonItems = 0;
     $sim = 0;
     foreach ($searchee["MemberAttributeWeight"] as $weight_searchee) {
         foreach ($candidate["MemberAttributeWeight"] as $weight_candidate) {
             if ($weight_searchee["attribute_id"] == $weight_candidate["attribute_id"]) {
                 $attribute = $this->controller->Attribute->find("first", array("conditions" => array("Attribute.id" => $weight_candidate["attribute_id"])));
                 //if ($attribute["attribute_type_id"]==$type){
                 $commonItems++;
                 $weight1 = $weight_searchee["weight"];
                 $weight2 = $weight_candidate["weight"];
                 $sim += pow($weight1 - $weight2, 2);
                 //}
             }
         }
     }
     if ($commonItems > 0) {
         $sim = sqrt($sim / $commonItems);
         $sim = 1 - tanh($sim);
         $maxItems = min(count($searchee["MemberAttributeWeight"]), count($candidate["MemberAttributeWeight"]));
         $sim = $sim * ($commonItems / $maxItems);
     }
     return $sim;
 }
开发者ID:redhattaccoss,项目名称:Qalanjo,代码行数:32,代码来源:match_maker.php

示例11: tanh

/**
 * Calculate TANH, within bounds.
 * 
 * @param
 *        	double d The value to calculate for.
 * @return double The result.
 */
function tanh($d)
{
    return \Encog\MathUtil\BoundNumbers\bound(\tanh($d));
}
开发者ID:katrinaniolet,项目名称:encog-php-core,代码行数:11,代码来源:BoundMath.php

示例12: tanh

 /**
  * {@inheritdoc}
  */
 public function tanh($angle)
 {
     return $this->withPrecision(tanh($angle));
 }
开发者ID:stillat,项目名称:common,代码行数:7,代码来源:BinaryCalculatorExpressionEngine.php

示例13: processCoth

 protected function processCoth()
 {
     $operands = $this->getOperands();
     $operand = $operands[0];
     if ($operand->getValue() == 0) {
         return null;
     } else {
         if (is_infinite($operand->getValue())) {
             return new Float(0.0);
         }
     }
     return new Float(1 / tanh($operand->getValue()));
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:13,代码来源:MathOperatorProcessor.php

示例14: var_dump

<?php

/* 
 * proto float tanh(float number)
 * Function is implemented in ext/standard/math.c
*/
$arg_0 = 1.0;
$extra_arg = 1;
echo "\nToo many arguments\n";
var_dump(tanh($arg_0, $extra_arg));
echo "\nToo few arguments\n";
var_dump(tanh());
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:tanh_error.php

示例15: coth

 /**
  * Calculates the hyperbolic cotangent of the parameter
  * 
  * @param float $x
  * @returns mixed A floating point on success, PEAR_Error object otherwise
  * @access public
  */
 function coth($x)
 {
     /*{{{*/
     $x = floatval($x);
     $tanh = tanh($x);
     if ($tanh == 0.0) {
         return PEAR::raiseError('Undefined operation, hyperbolic tangent of parameter is zero');
     } else {
         return 1 / $tanh;
     }
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:18,代码来源:TrigOp.php


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