By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 463,055 Members | 569 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,055 IT Pros & Developers. It's quick & easy.

# Correct return in plot but not when printing values of function

 P: 1 Hi. My code below: Expand|Select|Wrap|Line Numbers def simulate_stock(start,rate,vol,days):     daily_yields=np.random.normal(loc=(rate/252),scale=(vol/(252**0.5)),size=days)     cumulative_yields=np.cumsum(daily_yields)     daily_multipliers=np.exp(cumulative_yields)     simulated_prices = np.round(start * daily_multipliers, 2)     simulated_prices = np.concatenate(([start],simulated_prices))     return simulated_prices     def find_yield(run):     sim_price_length = len(simulated_prices)     final_price = simulated_prices[sim_price_length-1]     init_price = simulated_prices[0]     annual_yield = math.log(final_price/init_price, math.e)*(252/(days))     return annual_yield   i = 0 yield_list = [] for i in range(25):     simulations = simulate_stock(100,0.06,0.4,200)     plt.plot(simulations)     yield_val = find_yield(simulations)     yield_list.append(yield_val) Now when I plot different graphs as needed. When I print yield_list*I see a single array with an only value which doesn't make sense. What I am doing wrong? Regards 1 Week Ago #1
Share this question for a faster answer!

### Post your reply

Sign in to post your reply or Sign up for a free account.