本文整理汇总了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;
}
示例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);
}
示例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];
}
示例4: tanh
/**
* Returns the hyperbolic tangent of an angle.
*
* @param number $angle
* @return number
*/
public function tanh($angle)
{
return tanh($angle);
}
示例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);
}
示例6: tanh
/**
* @param float $x A number
* @return float The hyperbolic tangent of the given value
*/
public function tanh($x)
{
return tanh($x);
}
示例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===
示例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);
示例9: tanh
public static function tanh($self, $a)
{
return tanh($a);
}
示例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;
}
示例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));
}
示例12: tanh
/**
* {@inheritdoc}
*/
public function tanh($angle)
{
return $this->withPrecision(tanh($angle));
}
示例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()));
}
示例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());
示例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;
}
}