在python中使用子进程找不到文件错误

您需要创建一个函数来一次性处理输入、积分和绘图 ( sir_interactive_func),见下文:



# For integration.

import scipy.integrate 


# For arrays (Python does not have native arrays).

import numpy as np


# For graphing.

import matplotlib.pyplot as plt 


# Prevents the pop-up graphs in a separate window.

get_ipython().run_line_magic('matplotlib', 'inline')


# Allows for an interactive widget bar.

from ipywidgets import interactive 


S0 = 0.95

I0 = 0.05

R0 = 0.0




def SIR_model(y, t, beta, gamma):


    S, I, R = y

    

    dS_dt = -beta*S*I

    dI_dt = beta*S*I - gamma*I

    dR_dt = gamma*I

    

    return([dS_dt, dI_dt, dR_dt,])

    

def sir_interactive_func(beta, gamma):

    

    # Graph from 0 to 100, include 10000 points.

    t = np.linspace(0, 100, 10000) 

    

    solution = scipy.integrate.odeint(SIR_model, [S0, I0, R0], t, args=(beta, gamma))

    solution = np.array(solution)


    plt.figure(figsize=[8, 5])


    plt.plot(t, solution[:, 0], label="S(t)")

    plt.plot(t, solution[:, 1], label="I(t)")

    plt.plot(t, solution[:, 2], label="R(t)")


    plt.grid()

    plt.legend()


    plt.title("SIR Model")

    plt.xlabel("Time")

    plt.ylabel("Proportions of Populations")

    


interactive_plot = interactive(sir_interactive_func, beta=(0.35,1,0.01), gamma=(0.1,1,0.01))

interactive_plot



函数式编程
浏览 84回答 1
1回答

收到一只叮咚

要执行文件,您必须使用 './filename'通过阅读您的上述评论,您必须授予文件可执行权限,可以这样做:chmod +x ais其原因在这里得到了很好的解释:https://unix.stackexchange.com/a/4432/399463
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python