Python: Solving a complex scenario analysis

MathiasRa

I am interested in learning if there has been published some type of code or package that can help me with the following problem:

An event takes place 30 times.

Each event can return 6 different values (0,1,2,3,4,5), each with their own unique probability.

I would like to estimate the probability of the total values -after all the scenarios have been simulated - is above X (e.g. 24).

The issue I have is that I can't - in a given event where the value is 3- multiply the probability of value 3*3 and add it together with the previous obtained values. Instead I need to simulate every single variation that is possible.

Is there any relatively simple solution to solve this issue?

Ben

First of all, what you're describing isn't scenario analysis. That said, Python can be used to estimate complex probabilities where an analytical solution might be hard or impossible to find.

Assuming an event takes place 30 times, with outcomes [0,1,2,3,4,5], and each outcome has a probability of occurring given by the list (for example) p = [.1,.2,.2,.3,.1,.1], you can approximate the probability that the sum of all 30 events is greater than X with

import numpy as np

X = 80

np.mean([sum(np.random.choice(a=[0,1,2,3,4,5], size= 30,p=[.1,.2,.2,.3,.1,.1])) > X for i in range(10000)])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Solving complex PDEs in Python with FiPY

From Dev

Solving complex PDEs in Python with FiPY

From Dev

Python argparse: Complex Argument Parsing Scenario

From Dev

Complex Regex scenario

From Dev

Elastic Search Complex Scenario

From Dev

Python: Parsing a complex string into usable data for analysis

From Dev

Toggle layers on and off in Leaflet (more complex scenario)

From Dev

Excel offsets to suit complex autofill scenario

From Dev

Solving a complex recurrence relation for the Traveling Salesman

From Dev

Solving polynomials with complex coefficients using sympy

From Dev

Solving MySQL Complex parent and child Query

From Dev

Complex rolling scenario (CROSS APPLY and OUTER APPLY example)

From Dev

Complex groupby operation using Pandas to capture a many to one scenario

From Dev

Solving Equi task in python

From Dev

Solving process chaining in Python

From Dev

Solving PDE with sources in Python

From Dev

Maze solving with python

From Dev

Solving a graph issue with Python

From Dev

Solving ODE numerically with Python

From Dev

solving a Maze Using Python

From Dev

Solving equation in Python 3.3

From Dev

Solving process chaining in Python

From Dev

Maze Solving in Python

From Dev

Python solving goniometric equation

From Dev

How to manage this scenario with SonarLint? Differential analysis for changes of a branch

From Dev

How to manage this scenario with SonarLint? Differential analysis for changes of a branch

From Dev

C++ Libraries for solving Complex Linear systems Ax=b

From Dev

Python dict.get() or None scenario

From Dev

Python: solving unicode hell with unidecode