Reputation: 1
I'm relative new to C# and doing a project using Monte Carlo Simulation. Basically my question is the following.
I have two uncertain variable inputs, A and B, and they will go through a model and give an output C. So C = f(A,B). I know A's probability distribution (Triangular) and B's probability distribution (Discrete). How can I get the probability distribution of C?
What I have done now is that I can generate random numbers based on A's triangular distribution as well as B's discrete distribution. Each pair of randomly generated A and B gives a resultant C. I've run this model 1000 times thus I can get 1000 possible values of C. The difficulty is to get the corresponding probabilities of each value of C. Obviously it's not 1/1000 unless C is uniformly distributed. Is there any Monte Carlo Simulation package/library I can use?
Upvotes: 0
Views: 3034
Reputation: 80282
To gain an intuitive understanding of the concepts covered in the question, read The Flaw Of Averages by Sam Savage. It provides example code, demo projects, and spreadsheets showing how to model the question above.
Upvotes: 0
Reputation: 108810
Put them in a histogram.
For example create 1000 bins, each corresponding to a small interval. Then run the model TotalN=1000000 times and count how many values fall in each interval.
Then calculate n[i]/TotalN/WidthOfBin
to get the approximate probability density in that interval.
Upvotes: 2