本文整理汇总了Python中math.atanh函数的典型用法代码示例。如果您正苦于以下问题:Python atanh函数的具体用法?Python atanh怎么用?Python atanh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了atanh函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: correlation_MRRtest
def correlation_MRRtest(rx1y, rx2y, rx1x2, n):
"""Meng-Rosenthal-Rubin method comparing two correlated
correlation coefficients.
:param float rx1y: the correlation coefficient between variables x1 and y
:param float rx2y: the correlation coefficient between variables x2 and y
:param float rx1x2: the correlation coefficient between variables x1 and x2
:param int n: sample size
:return: two-tailed p-value
Reference: Meng et al. (1992), Psychol. Bull. 111, 172,
"""
assert (-1<=rx1y<=1) and (-1<=rx2y<=1) and (-1<=rx1x2<=1), \
"Correlation coefficients should be in ]-1,1["
from math import sqrt, atanh
z1 = atanh(rx1y) # Fisher's Z-transformation
z2 = atanh(rx2y)
rs = (rx1y**2 + rx2y**2)/2.
f = min((1 - rx1x2)/(2*(1 - rs)), 1)
h = (1 - f*rs) / (1 - rs)
dz = (z1 - z2) * sqrt((n - 3)/(2 * (1 - rx1x2) * h))
p = 2 * S.distributions.norm.sf(abs(dz)) # Two-tailed probability
return p
开发者ID:Traecp,项目名称:DEVA,代码行数:27,代码来源:Statistics.py
示例2: fromwgs84
def fromwgs84(lat, lng, pkm=False):
"""
Convert coordintes from WGS84 to TWD97
pkm true for Penghu, Kinmen and Matsu area
The latitude and longitude can be in the following formats:
[+/-]DDD°MMM'SSS.SSSS" (unicode)
[+/-]DDD°MMM.MMMM' (unicode)
[+/-]DDD.DDDDD (string, unicode or float)
The returned coordinates are in meters
"""
_lng0 = lng0pkm if pkm else lng0
lat = radians(todegdec(lat))
lng = radians(todegdec(lng))
t = sinh((atanh(sin(lat)) - 2*pow(n,0.5)/(1+n)*atanh(2*pow(n,0.5)/(1+n)*sin(lat))))
epsilonp = atan(t/cos(lng-_lng0))
etap = atan(sin(lng-_lng0) / pow(1+t*t, 0.5))
E = E0 + k0*A*(etap + alpha1*cos(2*1*epsilonp)*sinh(2*1*etap) +
alpha2*cos(2*2*epsilonp)*sinh(2*2*etap) +
alpha3*cos(2*3*epsilonp)*sinh(2*3*etap))
N = N0 + k0*A*(epsilonp + alpha1*sin(2*1*epsilonp)*cosh(2*1*etap) +
alpha2*sin(2*2*epsilonp)*cosh(2*2*etap) +
alpha3*sin(2*3*epsilonp)*cosh(2*3*etap))
return E*1000, N*1000
开发者ID:shupingT,项目名称:twd97,代码行数:29,代码来源:converter.py
示例3: test_atanh
def test_atanh(self):
import math
self.ftest(math.atanh(0), 0)
self.ftest(math.atanh(0.5), 0.54930614433405489)
self.ftest(math.atanh(-0.5), -0.54930614433405489)
raises(ValueError, math.atanh, 1.)
assert math.isnan(math.atanh(float("nan")))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_math.py
示例4: pwmTOu
def pwmTOu(pwm):
u = np.array([0.0,0.0])
u[0] = math.atanh((pwm[0]-1800)/200)+1
u[1] = math.atanh((pwm[1]-1500)/500)
return u
# # # FIN PARTIE SIMULATION # # #
开发者ID:UV57-ProjetGascogne2016,项目名称:Gascogne,代码行数:9,代码来源:simulateur.py
示例5: testAtanh
def testAtanh(self):
self.assertRaises(TypeError, math.atan)
self.ftest('atanh(0)', math.atanh(0), 0)
self.ftest('atanh(0.5)', math.atanh(0.5), 0.54930614433405489)
self.ftest('atanh(-0.5)', math.atanh(-0.5), -0.54930614433405489)
self.assertRaises(ValueError, math.atanh, 1)
self.assertRaises(ValueError, math.atanh, -1)
self.assertRaises(ValueError, math.atanh, INF)
self.assertRaises(ValueError, math.atanh, NINF)
self.assert_(math.isnan(math.atanh(NAN)))
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:10,代码来源:test_math.py
示例6: min_f
def min_f(self, a, b):
"""Custom minimum function using inverse hyperbolic function."""
if a >= 2:
a = 1.99
if a <= 0:
a = 0.01
if b >= 2:
b = 1.99
if b <= 0:
b = 0.01
return 1 - math.tanh(math.atanh(1 - a) + math.atanh(1 - b))
开发者ID:LEW21,项目名称:pw-taio,代码行数:11,代码来源:automata.py
示例7: correlation
def correlation(x, y):
"""Calculate correlation with p-value and confidence interval."""
assert len(x) == len(y)
#r, p = sp.stats.pearsonr(x, y)
#r, p = sp.stats.kendalltau(x, y)
r, p = sp.stats.spearmanr(x, y)
n = len(x)
stderr = 1.0 / math.sqrt(n-3)
delta = 1.96 * stderr
lower = math.tanh(math.atanh(r) - delta)
upper = math.tanh(math.atanh(r) + delta)
return dict(r=r, p=p, lower=lower, upper=upper)
开发者ID:Nie-yingchun,项目名称:dwilib,代码行数:12,代码来源:correlation.py
示例8: _constants
def _constants(self, stages, bits):
if self.func_mode == "circular":
s = range(stages)
a = [atan(2**-i) for i in s]
g = [sqrt(1 + 2**(-2*i)) for i in s]
#zmax = sum(a)
# use pi anyway as the input z can cause overflow
# and we need the range for quadrant mapping
zmax = pi
elif self.func_mode == "linear":
s = range(stages)
a = [2**-i for i in s]
g = [1 for i in s]
#zmax = sum(a)
# use 2 anyway as this simplifies a and scaling
zmax = 2.
else: # hyperbolic
s = []
# need to repeat some stages:
j = 4
for i in range(stages):
if i == j:
s.append(j)
j = 3*j + 1
s.append(i + 1)
a = [atanh(2**-i) for i in s]
g = [sqrt(1 - 2**(-2*i)) for i in s]
zmax = sum(a)*2
a = [int(ai*2**(bits - 1)/zmax) for ai in a]
# round here helps the width=2**i - 1 case but hurts the
# important width=2**i case
gain = 1.
for gi in g:
gain *= gi
return a, s, zmax, gain
开发者ID:RP7,项目名称:migen,代码行数:35,代码来源:cordic.py
示例9: fromGeographic
def fromGeographic(self, lat, lon):
lat_rad = radians(lat)
lon_rad = radians(lon)
B = cos(lat_rad) * sin(lon_rad - self.lon_rad)
x = self.radius * atanh(B)
y = self.radius * (atan(tan(lat_rad) / cos(lon_rad - self.lon_rad)) - self.lat_rad)
return x, y
开发者ID:Dancovich,项目名称:blender-addons-fork,代码行数:7,代码来源:transverse_mercator.py
示例10: compute
def compute(self, plug, data):
# Check if output value is connected
if plug == self.aOutputVaue:
# Get input datas
operationTypeHandle = data.inputValue(self.aOperationType)
operationType = operationTypeHandle.asInt()
inputValueXHandle = data.inputValue(self.aInputValueX)
inputValueX = inputValueXHandle.asFloat()
inputValueYHandle = data.inputValue(self.aInputValueY)
inputValueY = inputValueYHandle.asFloat()
# Math tanus
outputValue = 0
if operationType == 0:
outputValue = math.atan(inputValueX)
if operationType == 1:
outputValue = math.tan(inputValueX)
if operationType == 2:
outputValue = math.atanh(inputValueX)
if operationType == 3:
outputValue = math.tanh(inputValueX)
if operationType == 4:
outputValue = math.tanh(inputValueY, inputValueX)
# Output Value
output_data = data.outputValue(self.aOutputVaue)
output_data.setFloat(outputValue)
# Clean plug
data.setClean(plug)
开发者ID:AtonLerin,项目名称:Maya_Tools,代码行数:34,代码来源:QDTan.py
示例11: hyperbolic_fun_cal
def hyperbolic_fun_cal(inp_val1, opn_type):
oprn_dic = {
'1': 'inverse hyperbolic cosine of x', '2':'inverse hyperbolic sine of x',
'3':' inverse hyperbolic tangent of x', '4':'hyperbolic cosine of x',
'5':'hyperbolic sine of x', '6':'hyperbolic tangent of x'}
if int(opn_type) == 1:
output = math.acosh(float(inp_val1))
return str(output)
if int(opn_type) == 2:
output = math.asinh(float(inp_val1))
return str(output)
if int(opn_type) == 3:
output = math.atanh(float(inp_val1))
return str(output)
if int(opn_type) == 4:
output = math.cosh(float(inp_val1))
return str(output)
if int(opn_type) == 5:
output = math.sinh(float(inp_val1))
return str(output)
if int(opn_type) == 6:
output = math.tanh(float(inp_val1))
return str(output)
else:
return "Invalid Operation"
开发者ID:RajatShukla,项目名称:Test,代码行数:25,代码来源:math_calc.py
示例12: bachelierFormulaImpliedVol
def bachelierFormulaImpliedVol(optionType,
strike,
forward,
tte,
bachelierPrice,
discount=1.0):
strike = float(strike)
forward = float(forward)
tte = float(tte)
bachelierPrice = float(bachelierPrice)
discount = float(discount)
pyFinAssert(tte > 0, ValueError, "tte ({0:f}) must be positive".format(tte))
SQRT_QL_EPSILON = math.sqrt(MathConstants.QL_EPSILON)
forwardPremium = bachelierPrice / discount
if optionType == OptionType.Call:
straddlePremium = 2.0 * forwardPremium - (forward - strike)
else:
straddlePremium = 2.0 * forwardPremium + (forward - strike)
nu = (forward - strike) / straddlePremium
nu = max(-1.0 + MathConstants.QL_EPSILON, min(nu, 1.0 - MathConstants.QL_EPSILON))
eta = 1.0 if (abs(nu) < SQRT_QL_EPSILON) else (nu / math.atanh(nu))
heta = HCalculator.calculate(eta)
impliedBpvol = math.sqrt(MathConstants.M_PI / (2 * tte)) * straddlePremium * heta
return impliedBpvol
开发者ID:thierbig,项目名称:Finance-Python,代码行数:29,代码来源:BlackFormula.py
示例13: __init__
def __init__(self, file_name):
proc = subprocess.Popen("../bin/meas_moments %s" % file_name, stdout=subprocess.PIPE, shell=True)
buf = os.read(proc.stdout.fileno(), 1000)
while proc.poll() == None:
pass
if proc.returncode != 0:
raise RuntimeError("meas_moments exited with an error code")
results = buf.split()
if results[0] is not "0":
raise RuntimeError("meas_moments returned an error status")
self.mxx = float(results[1])
self.myy = float(results[2])
self.mxy = float(results[3])
self.e1 = float(results[4])
self.e2 = float(results[5])
# These are distortions e1,e2
# Find the corresponding shear:
esq = self.e1 * self.e1 + self.e2 * self.e2
if esq > 0.0:
e = math.sqrt(esq)
g = math.tanh(0.5 * math.atanh(e))
self.g1 = self.e1 * (g / e)
self.g2 = self.e2 * (g / e)
else:
self.g1 = 0.0
self.g2 = 0.0
开发者ID:lmoustakas,项目名称:GalSim,代码行数:27,代码来源:Demo.py
示例14: test_funcs_multi
def test_funcs_multi(self):
pi = math.pi
# sin family
self.assertQuantity(data.sin(Quantity( (0,pi/2), (2,2))), (0,1), (2,0))
self.assertQuantity(data.sinh(Quantity((0,1), (2,2))), (0, math.sinh(1)), (2, math.cosh(1)*2))
self.assertQuantity(data.asin(Quantity((0,0.5), (2,2))), (0,math.asin(0.5)), (2,2/math.sqrt(1-0.5**2)))
self.assertQuantity(data.asinh(Quantity((0,1), (2,2))), (0,math.asinh(1)), (2,2/math.sqrt(1+1**2)))
# cos family
self.assertQuantity(data.cos(Quantity((0,pi/2), (2,2))), (1,0), (0,-2))
self.assertQuantity(data.cosh(Quantity((0,1), (2,2))), (1,math.cosh(1)), (0,math.sinh(1)*2))
self.assertQuantity(data.acos(Quantity((0,0.5), (2,2))), (math.acos(0),math.acos(0.5)), (-2,-2/math.sqrt(1-0.5**2)))
self.assertQuantity(data.acosh(Quantity((2,3), (2,2))), (math.acosh(2), math.acosh(3)), (2/math.sqrt(2**2-1),2/math.sqrt(3**2-1)))
# tan family
self.assertQuantity(data.tan(Quantity((0,1), (2,2))), (0,math.tan(1)), (2,2/math.cos(1)**2))
self.assertQuantity(data.tanh(Quantity((0,1), (2,2))), (0,math.tanh(1)), (2,2/math.cosh(1)**2))
self.assertQuantity(data.atan(Quantity((0,1), (2,2))), (0, math.atan(1)), (2,2/(1+1**2)))
self.assertQuantity(data.atan2(Quantity((0,1), (2,2)), Quantity((1,1), (0,0))), (0,math.atan(1)), (2,2/(1+1**2)))
self.assertQuantity(data.atanh(Quantity((0,0.5), (2,2))), (0,math.atanh(0.5)), (2,2/(1-0.5**2)))
#misc
self.assertQuantity(data.sqrt(Quantity((1,4), (2,2))), (1,2), (1,1/2))
self.assertQuantity(data.exp(Quantity((1,4), (2,2))), (math.e, math.e**4), (2 * math.e,2*math.e**4))
self.assertQuantity(data.log(Quantity((1,4), (2,2))), (0, math.log(4)), (2,1/2))
开发者ID:esel7353,项目名称:ephys,代码行数:26,代码来源:data.py
示例15: g1g2_to_eta1eta2
def g1g2_to_eta1eta2(g1,g2):
gtot=sqrt(g1**2 + g2**2)
if isinstance(gtot,numpy.ndarray):
eta1=numpy.zeros(gtot.size)
eta2=numpy.zeros(gtot.size)
w,=numpy.where(gtot != 0)
if w.size > 0:
cos2theta=g1[w]/gtot[w]
sin2theta=g2[w]/gtot[w]
eta = 2*arctanh(gtot[w])
eta1[w]=eta*cos2theta
eta2[w]=eta*sin2theta
else:
from math import atanh
if gtot == 0:
eta1,eta2=0.0,0.0
else:
cos2theta=g1/gtot
sin2theta=g2/gtot
eta = 2*atanh(gtot)
eta1=eta*cos2theta
eta2=eta*sin2theta
return eta1,eta2
开发者ID:esheldon,项目名称:espy,代码行数:27,代码来源:util.py
示例16: test_shearest_basic
def test_shearest_basic():
"""Test that we can recover shears for Gaussian galaxies and PSFs."""
for sig in gaussian_sig_values:
for g1 in shear_values:
for g2 in shear_values:
total_shear = np.sqrt(g1**2 + g2**2)
conversion_factor = np.tanh(2.0*math.atanh(total_shear))/total_shear
distortion_1 = g1*conversion_factor
distortion_2 = g2*conversion_factor
gal = galsim.Gaussian(flux = 1.0, sigma = sig)
psf = galsim.Gaussian(flux = 1.0, sigma = sig)
gal = gal.shear(g1=g1, g2=g2)
psf = psf.shear(g1=0.1*g1, g2=0.05*g2)
final = galsim.Convolve([gal, psf])
final_image = final.drawImage(scale=pixel_scale, method='no_pixel')
epsf_image = psf.drawImage(scale=pixel_scale, method='no_pixel')
result = galsim.hsm.EstimateShear(final_image, epsf_image)
# make sure we find the right e after PSF correction
# with regauss, which returns a distortion
np.testing.assert_almost_equal(result.corrected_e1,
distortion_1, err_msg = "- incorrect e1",
decimal = decimal_shape)
np.testing.assert_almost_equal(result.corrected_e2,
distortion_2, err_msg = "- incorrect e2",
decimal = decimal_shape)
开发者ID:esheldon,项目名称:GalSim,代码行数:25,代码来源:test_hsm.py
示例17: set_e1e2
def set_e1e2(self, e1, e2):
etot = sqrt(e1**2 + e2**2)
if etot >= 1:
mess="e values must be < 1, found %.16g (%.16g,%.16g)"
mess = mess % (etot,e1,e2)
raise ShapeRangeError(mess)
if etot==0:
self.eta1,self.eta2,self.g1,self.g2=(0.,0.,0.,0.)
self.e1,self.e2=(0., 0.)
return
eta = atanh(etot)
gtot = tanh(eta/2)
cos2theta = e1/etot
sin2theta = e2/etot
self.e1=e1
self.e2=e2
self.g1=gtot*cos2theta
self.g2=gtot*sin2theta
self.eta1=eta*cos2theta
self.eta2=eta*sin2theta
开发者ID:esheldon,项目名称:espy,代码行数:25,代码来源:shear.py
示例18: atanh
def atanh(space, d):
""" atanh - Inverse hyperbolic tangent """
try:
return space.wrap(math.atanh(d))
except OverflowError:
return space.wrap(rfloat.INFINITY)
except ValueError:
return space.wrap(rfloat.NAN)
开发者ID:AirBayCreative,项目名称:hippyvm,代码行数:8,代码来源:funcs.py
示例19: adjustValue
def adjustValue(value):
pMark = 0.65 #> percentage mark where values gets pushed up or down
result = value + (1.5*math.atanh(value - pMark)) * value
upperLimit = 0.9
lowerLimit = 0.0
result = min(result,upperLimit)
result = max(result,lowerLimit)
return result
开发者ID:theunknowner,项目名称:Pyth,代码行数:8,代码来源:statsign.py
示例20: convertToShear
def convertToShear(e1,e2):
# Convert a distortion (e1,e2) to a shear (g1,g2)
import math
e = math.sqrt(e1*e1 + e2*e2)
g = math.tanh( 0.5 * math.atanh(e) )
g1 = e1 * (g/e)
g2 = e2 * (g/e)
return (g1,g2)
开发者ID:plazas,项目名称:GalSim,代码行数:8,代码来源:galsim_test_helpers.py
注:本文中的math.atanh函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论