Cost benefit analysis with varying discount rates
收藏NIAID Data Ecosystem2026-05-01 收录
下载链接:
https://data.mendeley.com/datasets/gdh35w7mkv
下载链接
链接失效反馈官方服务:
资源简介:
This code performs a cost-benefit analysis by plotting the Net Present Value (NPV) over time for different discount rates. It uses matplotlib to generate the visualizations.
Here's a breakdown of what the code does:
It imports the necessary libraries, matplotlib.pyplot and numpy, which are commonly used for plotting and numerical operations, respectively.
It defines a time range T using numpy's arange function, which generates an array of numbers from 0 to 10 with a step size of 0.1, representing time in years.
It defines two functions cost_function(t) and benefit_function(t) that represent the cost and benefit functions over time. These functions are defined using mathematical expressions.
It creates a list discount_rates containing different discount rates to explore.
It sets up a figure with a specific size using plt.figure(figsize=(10, 6)) to adjust the dimensions of the plot.
It iterates over each discount rate in the discount_rates list.
Inside the loop, it calculates the NPV for each discount rate at different time points using the provided cost and benefit functions and the formula for NPV.
It plots the NPV over time using plt.plot(T, NPV, label=f'Discount Rate = {r}'), where T is the time range and NPV is the calculated Net Present Value for the current discount rate r. It also labels each plot with the corresponding discount rate.
It adds labels to the x-axis (Time (years)) and y-axis (Net Present Value), sets the title of the plot (Cost-Benefit Analysis with Varying Discount Rates), adds a legend to distinguish between different discount rates, and enables grid lines for better readability.
Finally, it displays the plot using plt.show().
In summary, this code allows for the comparison of the Net Present Value over time under different discount rates, providing insights into the financial viability of a project or investment.
创建时间:
2024-03-27



