chris1610 / pbpython

Code, Notebooks and Examples from Practical Business Python
https://pbpython.com
BSD 3-Clause "New" or "Revised" License
1.98k stars 987 forks source link

About Monte Carlo Simulation #24

Open Kavan72 opened 3 years ago

Kavan72 commented 3 years ago

@chris1610 First, Thanks for the good example of MonteCarlo Simulation.

I'm trying to implement MonteCarlo for risk analysis. This is my simple data

image

On this data i've two types of asset value and also each asset value has high and low values. I'm trying to get risk value of each given percentage. Can you pls help me out how to fit two values in your code ?

and do you have discord account ?

chris1610 commented 3 years ago

@Kavan72 - I do not have a discord account. Maybe some time in the future but not right now.

What I would recommend doing is starting with identifying which columns you want to model with a distribution.

From what I can tell, you have an event risk 5-100%. You will need to define what that distribution looks like. For instance if it is a normal distribution with a mean of .5 and std deviation of .2 then you can generate 10 examples using this code:

np.random.normal(.5, .2, 10)

The trick is figuring out the distribution type and shape (via mean and std deviation)

It also seems like your other variable is CPH which has a much wider std deviation. Maybe you do something like this:

np.random.normal(150000, 50000, 10)

The key is to try some of these values and see if it intuitively makes sense based on your understanding of the underlying data.

Does this help? I may not be understanding your data exactly but this is my first thought.

Kavan72 commented 3 years ago

Ohh sorry i made you confused, forgot about this dataset.

just i've 4 values

  1. CI Low = $ 20,000
  2. CI High = $ 250,000
  3. AV Low CPH = $ 100
  4. AV High CPH = $ 250

now, i wanted to find loss in between 5-100%, that's it.

chris1610 commented 3 years ago

In your example, how would you calculate the loss? Maybe if I see the math of 1 example it will make sense to me.