Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results not being produced #74

Closed
wijdan225 opened this issue Nov 13, 2020 · 2 comments
Closed

Results not being produced #74

wijdan225 opened this issue Nov 13, 2020 · 2 comments

Comments

@wijdan225
Copy link

Hi Jason - this is a newbie question. I'm trying to run the following code in Jupyter notebook but I'm not getting any output...it just sits there like I never pressed run.


import pyesg

model = pyesg.GeometricBrownianMotion(mu = 0.05, sigma = 0.2)

x0 = 100
dt = 1
n_scenarios = 1000
n_steps = 60
random_state = 123

results = model.scenarios(x0, dt, n_scenarios, n_steps, random_state)


I've tried other code to test there's nothing else wrong but I don't think there is. For example, when I run...

import pyesg

mu = 0.05
sigma = 0.2
x0 = 100
dt = 10

pyesg.GeometricBrownianMotion(mu, sigma).expectation(x0, dt)

...I get:
array([134.98588076])

Can you help?!

Wijdan

@jason-ash
Copy link
Owner

Hi Wijdan, thanks for reaching out! I'm thinking the solution could be pretty easy. It looks like you saved the scenarios as a variable called results. If all you do it run your first cell, it won't display any results, but they have been created and saved into the results variable. To view the scenarios, you can just type results into a new cell and run it, or you could use them in future calculations. Here's another way to do it in a Python terminal.

Hope this helps! Thanks for using pyesg!

>>> import pyesg
>>> model = pyesg.GeometricBrownianMotion(mu=0.05, sigma=0.2)
>>> x0, dt, n_scenarios, n_steps, random_state = 100., 1., 1000, 60, 123
>>> results = model.scenarios(x0, dt, n_scenarios, n_steps, random_state)
>>> results
array([[ 100.        ,   82.9339133 ,   73.57303396, ..., 1211.59790042,
        1248.84917851, 1311.81842548],
       [ 100.        ,  125.79319831,  145.20669651, ..., 2884.74460192,
        2889.50398806, 2626.40753946],
       [ 100.        ,  109.04557189,  129.72229771, ..., 1999.63993254,
        2402.35984907, 2514.35338758],
       ...,
       [ 100.        ,   85.91039055,   82.38846502, ..., 1377.10559491,
        1069.92548345,  847.91925163],
       [ 100.        ,  113.20755859,   84.54499845, ..., 1264.9149978 ,
         847.60201606,  799.59775636],
       [ 100.        ,   82.50707906,   85.25085188, ...,  372.08216317,
         373.96921386,  424.49526126]])
>>>

@wijdan225
Copy link
Author

Thanks very much Jason - that worked perfectly (knew it was a rookie error!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants