1. 用python编写:输入n对数,输出其中max与min。
a = input()
max(a)
min(a)
第一行注意下输入的格式和类型。
python里面自带max和min方法。不用再去对元组或列表进行排序,找最大值最小值
2. python 怎么用log函数
import sys
funcName = sys._getframe().f_back.f_code.co_name #获取调用函数名
lineNumber = sys._getframe().f_back.f_lineno #获取行号
print sys._getframe().f_code.co_name # 获取当前函数名
3. python里有内置的求对数的函数么
在python中有内置的求对数的函数。
log()方法返回x的自然对数,对于x>0。
语法
以下是log()方法的语法:
#!/usr/bin/python
import math # This will import math mole
print "math.log(100.12) : ", math.log(100.12)
print "math.log(100.72) : ", math.log(100.72)
print "math.log(119L) : ", math.log(119L)
print "math.log(math.pi) : ", math.log(math.pi)
当我们运行上面的程序,它会产生以下结果:
math.log(100.12) : 4.60636946656
math.log(100.72) : 4.61234438974
math.log(119L) : 4.77912349311
math.log(math.pi) : 1.14472988585
4. 如何使用python 对一个一维向量取对数
此方法返回x的自然对数,对于x>0。
例子
下面的例子显示了log()方法的用法。
?
1
2
3
4
5
6
7
#!/usr/bin/python
import math # This will import math mole
print "math.log(100.12) : ", math.log(100.12)
print "math.log(100.72) : ", math.log(100.72)
print "math.log(119L) : ", math.log(119L)
print "math.log(math.pi) : ", math.log(math.pi)
当我们运行上面的程序,它会产生以下结果:
?
1
2
3
4
math.log(100.12) : 4.
math.log(100.72) : 4.
5. 如何用python拟合对数函数
scipy的optimize工具箱中有拟合函数可以使用 或者用sm的OSL进行拟合 具体搜一下教程
6. 如何使用python中的math
首先,导入math函数库。
一、计算平方根
输入一个数值,保存在变量n中。
相关推荐:《Python基础教程》
用函数sqrt,计算变量平方根的值。
二、计算幂
可以用函数exp,计算e的x次幂。
三、计算对数
设置两个数,保存在变量n和a中。
接着,用log函数计算以a为基数n的对数。
运行程序,其结果如下图所示。
7. python dataframe 求对数
log()方法返回x的自然对数,对于x>0。
语法
以下是log()方法的语法:
import math
math.log( x )
注意:此函数是无法直接访问的,所以我们需要导入math模块,然后需要用math的静态对象来调用这个函数。
参数
x -- 这是一个数值表达式。
返回值
此方法返回x的自然对数,对于x>0。
例子
下面的例子显示了log()方法的用法。
#!/usr/bin/python
import math # This will import math mole
print "math.log(100.12) : ", math.log(100.12)
print "math.log(100.72) : ", math.log(100.72)
print "math.log(119L) : ", math.log(119L)
print "math.log(math.pi) : ", math.log(math.pi)
当我们运行上面的程序,它会产生以下结果:
math.log(100.12) : 4.60636946656
math.log(100.72) : 4.61234438974
math.log(119L) : 4.77912349311
math.log(math.pi) : 1.14472988585
8. 在python中怎么利用自然对数e
importmath
math.exp(1)#这行的值是e
9. python 如何设置对数坐标
请问同学是使用matlpot画图是么?
绘制对数坐标图的函数有三个:semilogx()、semilogy()和loglog(),它们分别绘制X轴为对数坐标、Y轴为对数坐标以及两个轴都为对数坐标时的图表。
希望能够帮到你~
10. Python中如何对series里所有的值取对数
以后应多使用论坛中的Eviews专区。
ln在Eviews中表示为log,如数学中的ln(Q)在Eviews中表示为log(Q)
直接定义啊 y=log(x) 在软件中log,论文模型中ln不用取对数直接在估计的时候用 log( )就好了
如果真要取的话
quick\ generate series\
输入新变量,比如 r=log( )
r就是取完对数后的序列
在工作文件中先定义一个新的变量Y(假设原变量是w,已存在的变量),然后在工作文件中点击genr,在方程中输入Y=log(w),确定。
series y=log(x)
在最小二乘里面输入log(y) log(x) c也可以
产生个新变量:输入命令y=log()