Python使用matplotlib繪制Logistic曲線操作示例
本文實例講述了Python使用matplotlib繪制Logistic曲線操作。分享給大家供大家參考,具體如下:
標準Logistic函數(shù)為:
f(x) = 1 / ( 1 + exp(-x) )
其導函數(shù)為:
f'(x) = f(x) * ( 1 - f(x) )
下面使用matplotlib繪制邏輯斯蒂函數(shù)及其導函數(shù)的曲線。
Python代碼:
# -*- coding:utf-8 -*- #!python3 import numpy as np import matplotlib.pyplot as plt a = np.linspace(-10, 10, 1000) b = 1.0 / (1.0 + np.exp(-a)) c = b * (1 - b) plt.subplot(2, 1, 1) plt.title('f(x) = 1 / ( 1 + exp(-x) )') plt.plot(a, b) plt.subplot(2, 1, 2) plt.title('f\'(x) = f(x) * ( 1 - f(x) )') plt.plot(a, c) plt.show()
運行結(jié)果:
更多關于Python相關內(nèi)容感興趣的讀者可查看本站專題:《Python數(shù)學運算技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門與進階經(jīng)典教程》
希望本文所述對大家Python程序設計有所幫助。
相關文章
python3 如何使用 goto 跳轉(zhuǎn)執(zhí)行到指定代碼行
這篇文章主要介紹了python3 使用goto跳轉(zhuǎn)執(zhí)行到指定代碼行的操作,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-05-05python神經(jīng)網(wǎng)絡Pytorch中Tensorboard函數(shù)使用
這篇文章主要為大家介紹了python神經(jīng)網(wǎng)絡Pytorch中Tensorboard常用函數(shù)的使用示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-05-05Python中threading庫實現(xiàn)線程鎖與釋放鎖
threading用于提供線程相關的操作,為了保證安全的訪問一個資源對象,我們需要創(chuàng)建鎖。那么Python線程鎖與釋放鎖如何實現(xiàn),感興趣的小伙伴們可以參考一下2021-05-05