新聞中心
如何用python求解一個帶正態(tài)分布和ln函數(shù)的方程
import scipy.stats as sta
我們提供的服務有:網(wǎng)站設計制作、網(wǎng)站設計、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、凌河ssl等。為近1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的凌河網(wǎng)站制作公司
import math
def option_call(s,x,r,sigma,t):
d1=(math.log(s/x)+(r+sigma**2/2)*t)/(math.sqrt(t)*sigma)
d2=d1-sigma*math.sqrt(t)
c=s*sta.norm.cdf(d1,0,1)-x*sta.norm.cdf(d2,0,1)*math.exp(-r*t)
return c
如何用python輸出8e的三次ln2
1、首先打開電腦中的編程軟件。
2、其次創(chuàng)建一個python主函數(shù)。
3、最后通過程序代碼輸出8e的三次ln2即可。
如何使用python的matplotlib畫正弦函數(shù)圖像
使用python的matplotlib畫正弦函數(shù)圖像,還要用到numpy庫,代碼如下9行所示:
import numpy as np;
from matplotlib import pyplot as plt;
fig = plt.figure();
ax2= fig.add_subplot(111);
x=np.arange(0,100)/10;
y=np.sin(x);
ax2.plot(x,y);
plt.savefig('sine.png');
plt.show();
python中l(wèi)n(π +1)怎么表示
import math
res = math.log(math.pi+1,math.e)
import math #導入math數(shù)據(jù)庫
a=math.pi #令一個值為a
用a來代替π在函數(shù)中的運算就可以
比如寫三角錐的公式中用a來代替π的位置。
擴展資料:
根據(jù)PEP的規(guī)定,必須使用4個空格來表示每級縮進(不清楚4個空格的規(guī)定如何,在實際編寫中可以自定義空格數(shù),但是要滿足每級縮進間空格數(shù)相等)。使用Tab字符和其它數(shù)目的空格雖然都可以編譯通過,但不符合編碼規(guī)范。支持Tab字符和其它數(shù)目的空格僅僅是為兼容很舊的的Python程序和某些有問題的編輯程序。
參考資料來源:百度百科-Python
python畫正余弦函數(shù)圖像?
用python怎樣畫出如題所示的正余弦函數(shù)圖像? 如此編寫代碼,使其中兩個軸、圖例、刻度,大小,LaTex公式等要素與原圖一致,需要用到的代碼如下,沒有縮進:
#-*-codeing:utf-8;-*-
from matplotlib import pyplot as plt
import numpy as np
a=np.linspace(0,360,980)
b=np.sin(a/180*np.pi)
c=np.cos(a/180*np.pi)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xlim([0, 360])
ax.plot(a,b,label=r"$y=\sin(\theta)$")
ax.plot(a,c,label=r"$y=\cos(\theta)$")
ax.grid(True)
ax.set_ylabel(r"$y$")
ax.set_xlabel(r"$\theta$")
plt.xticks(np.arange(0,360+1,45))
plt.title("Sine Cosine Waves")
plt.legend()
plt.savefig("SinCosWaveDegFont.jpg")
plt.show()
代碼運行show的窗口圖
代碼的截圖
代碼輸出的文件的圖
當前標題:python畫ln函數(shù) python調(diào)用ln函數(shù)
當前地址:http://www.ef60e0e.cn/article/dodheso.html