Тёмный

A Simple Solution for Really Hard Problems: Monte Carlo Simulation 

RiskByNumbers
Подписаться 7 тыс.
Просмотров 176 тыс.
50% 1

Today's video provides a conceptual overview of Monte Carlo simulation, a powerful, intuitive method to solve challenging probability questions. And we get to see how we can use it to answer a realistic question in Python!
0:00 Monte Carlo Applications
0:22 Party Problem: What is The Chance You'll Make It?
1:16 Monte Carlo Conceptual Overview
3:00 Monte Carlo Simulation in Python: NumPy and matplotlib
5:02 Party Problem: What Should You Do?
You can access the dataset and Jupyter Notebook used to run these scripts, which includes proper commenting, at: github.com/RiskByNumbers/Mont....
#montecarlosimulation #probability #datascience #python #numpy #tutorial #sampling
=====================
Hello, and welcome to RiskByNumbers!
I am a professor sharing educational resources around probability, statistics, optimization methods, algorithms, and programming to a broad audience.
Outside of RU-vid, you can currently find me in Vancouver, Canada at the University of British Columbia.
Thank you, and I look forward to seeing you in future videos!
Email: RiskByNumbers@gmail.com.
LinkedIn: / omar-swei

Опубликовано:

 

31 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 136   
@RichardRietdijk
@RichardRietdijk 3 месяца назад
“Alexa, tell Chatgpt to write my 2 reports. And message Monty and Carlo that I’m on my way to the BBQ. “
@RiskByNumbers
@RiskByNumbers 2 месяца назад
🤣 @RichardRietdijk: one of the best comments received yet -- it made my night!
@vitor00
@vitor00 15 дней назад
Great video! It took me about 15 minutes to set up the convolution integral, and do all the algebra to get the same result: 1/8.
@RiskByNumbers
@RiskByNumbers 15 дней назад
Thanks, @vitor00! Also glad that you were able to work out the analytical solution -- well done!
@mechros4460
@mechros4460 7 месяцев назад
How does this video not have many views? Well done, very clear and interesting.
@RiskByNumbers
@RiskByNumbers 7 месяцев назад
Thank you for the positive feedback and kind note -- I sincerely appreciate it!
@zp5808
@zp5808 5 месяцев назад
You can tell Todd, that one of the tasks will be ready. Freshly waiting for him on his deck, and the next one will be on his desk the next morning.
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
Poor Todd, @zp5808. He's really just upset that he was not invited to the BBQ. 😂
@zp5808
@zp5808 5 месяцев назад
@@RiskByNumbers 🤣
@andrewevanyshyn1709
@andrewevanyshyn1709 5 месяцев назад
Even with a background in probability, Monte Carlo is still used frequently. This is because even in simple scenarios calculating the expected value becomes very complex very quickly.
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
Definitely true! Thanks for providing this feedback.
@jameslinzmeier368
@jameslinzmeier368 2 месяца назад
Well he certainly isn't saving time running this simulation before getting to work.......
@RiskByNumbers
@RiskByNumbers 2 месяца назад
LOL @jameslinzmeier368, touché!
@matholive6994
@matholive6994 4 месяца назад
Although trivial example for demonstration that you can get away with CLT and sum of two Gaussian for easier approximate (mean 7 and std 1.632), very good explanation of Monte Carlo simulation for freshman
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Thanks, @matholive6994! Definitely a simple example that you could solve through alternative means. When I find the time, I'm going to create a blog where I can discuss in greater depth the different ways to solve a problem like this one. Thanks again for the kind words!
@eamonmolloy8308
@eamonmolloy8308 4 месяца назад
Beautiful, brief and very informative. Well done
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Thank you, @eamonmolloy8308! Sincerely appreciative of the kind note.
@azkaazmi1374
@azkaazmi1374 3 дня назад
Thankyou sir, great video i am a research scholar, and wanna apply on my research, ur video has cleared MCS concepts, thanx
@adamjc86
@adamjc86 2 месяца назад
This was an excellent demonstration, thank you
@RiskByNumbers
@RiskByNumbers 2 месяца назад
Thank you, @adamjc86, for the kind comment! Really appreciate it.
@pedrocolangelo5844
@pedrocolangelo5844 3 месяца назад
Such a great video, thank you so much for it. You got another subscriber!
@RiskByNumbers
@RiskByNumbers 3 месяца назад
Thank you, @pedrocolangelo5844, for the really kind message! I'll be getting the next video finally out next week!
@KpxUrz5745
@KpxUrz5745 17 дней назад
Very helpful, this is exactly what I've been looking to do in Python.
@RiskByNumbers
@RiskByNumbers 15 дней назад
Thank you, @KpxUrz574! I really appreciate the positive feedback.
@altr0403
@altr0403 4 месяца назад
Great video. Simple and useful. Thanks!
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Thanks, @altr0403! Your kind note means a lot. Thanks as well for subscribing!
@imyashbhatt
@imyashbhatt Месяц назад
Nice, informative, and to-the-point video. Thanks for the video and explanation.
@RiskByNumbers
@RiskByNumbers Месяц назад
Thanks, @imyashbhatt! I appreciate the kind words.
@cjspear
@cjspear 5 месяцев назад
Thank you for the simple explanation.
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
Many thanks!
@helenaredbone8585
@helenaredbone8585 5 месяцев назад
This video makes Monte Carlo Simulation easy to understand. Thank you, I wish I had my prof being able to explain that simply
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Thank you for the kind note! I really appreciate it.
@hannukoistinen5329
@hannukoistinen5329 3 месяца назад
This video is just crap. Nothing else!! Monte Carlo is NOT by any means used in statistics or data sceince.
@othmanmurad5267
@othmanmurad5267 2 месяца назад
This was much simpler than what I was expecting. Wish you create a video on MCMC as well.
@RiskByNumbers
@RiskByNumbers 2 месяца назад
Thanks, @othmanmurad5267! That was the goal of the video, so I'm glad it resonated with you. And, yes, definitely intending to put together a video on Markov chain Monte Carlo in the not too distant future.
@YuXingSong
@YuXingSong 22 дня назад
thanks for explain it so clearly that even i can understand
@RiskByNumbers
@RiskByNumbers 22 дня назад
Thanks for the kind words, @YuXingSong!
@OutOfRangeDE
@OutOfRangeDE 4 месяца назад
Nice presentation of the power of Monte Carlo. Also used in all its glory (many parameters) in analog integrated circuit design.
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Thanks, @OutOfRangeDE, for highlighting another application for Monte Carlo! It has been neat to hear from many folks around how they've applied Monte Carlo simulation. Your comment sent me down a 30-minute rabbit hole of reading up on its use for circuit designs -- its been great to learn via the comments.
@KinomaroMakhosini
@KinomaroMakhosini Месяц назад
Monte carlo is so intuitive i thought of it before i knew it was a thing
@RiskByNumbers
@RiskByNumbers 29 дней назад
Haha that is awesome, @KinomaroMakhosini!
@bernardogeocometto5562
@bernardogeocometto5562 Месяц назад
Really intuitive and cool
@RiskByNumbers
@RiskByNumbers Месяц назад
@bernardogeocometto5562: thank you!
@LiamRohan_
@LiamRohan_ Месяц назад
Hi Omar, really enjoying the way you teach. Is there any advise you have to those new to probability theory, where to start etc for those interesting in the practical application of risk? It's fascinating!
@RiskByNumbers
@RiskByNumbers Месяц назад
@LiamRohan_: really great question, and thanks for the positive feedback! In terms of learning about probability theory itself, I find that there are less 'accessible' resources than those related to statistics. This may be due to the fact that it is quite easy these days to import different libraries and use them to estimate a model. Having said that, I think that MIT OCW has a great primer on probability via 18.05. If you want to purchase a text, Ang and Tang have a good text titled 'Probability Concepts in Engineering' that I've seen used for courses in civil engineering, nuclear engineering, mining, and others. Now, there are even less resources in terms of practical application of risk analysis. Richard de Neufville is one author/researcher who comes to mind that provides practical resources around risk analysis and modeling for real problems. He focuses quite a bit on flexibility (which, in principle, underlies methodologies such as reinforcement learning) to better handle uncertainty and discusses so via quantitative as well as qualitative means. Is there a particular application you are working on these days?
@johnmaskell5124
@johnmaskell5124 5 месяцев назад
It would be great to have a video where you simulate the time to do both reports but where the time to do report 2 has some dependency on report 1.
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
Thanks for the suggestion, @johnmaskell5124! I really enjoy the intuition and simplicity of Cholesky decomposition when introducing folks to generating correlated random variables, so I'll plan on adding that to the list of future videos. Given the time it takes to create each of these animated videos, I am thinking that I'll make a blog soon, where I can provide more rapid thoughts on these topics. I'll announce that once I've set it up. Thanks again for your comment -- Omar
@x12_79
@x12_79 5 месяцев назад
Tod has a 100% chance of receiving a letter of resignation
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
🤣
@muzahmad2104
@muzahmad2104 6 месяцев назад
Very nice video. One of the best I’ve come across. It’d be great to cover when probabilities aren’t evenly distributed.
@RiskByNumbers
@RiskByNumbers 6 месяцев назад
Really appreciate the comment and feedback, @muzahmad2104! Now that I've received quite a few comments around distribution selection, I'm switching up the order of upcoming videos and having the next one focus on that topic. The comments received have been really valuable in determining what to focus on next. Thanks again for the feedback and positive note!
@muzahmad2104
@muzahmad2104 6 месяцев назад
its a pleasure, look forward to it. Keep up the good work
@briancruz3551
@briancruz3551 Месяц назад
Beautify stuff! And nice visuals, where do you edit your visuals?
@RiskByNumbers
@RiskByNumbers Месяц назад
Thanks, @briancruz3551! I appreciate the kind words. For the visuals in this video, I relied on a few tools. First, for the graphical animations (e.g., the Monte Carlo sampling), I wrote up a small Python script. I am doing that more and more in my videos, primarily with matplotlib.animation. As I use matplotlib so frequently for work, I have used to date, but this summer I'll explore other libraries. Second, for the screen recording I used OBS Studio (which is free!). Finally, to bring all the animated clips together, I use Premiere Pro. Launching this channel has given me a much greater appreciation around other channels that I watch on RU-vid in terms of their time and effort! Final exams end this Friday for me, so I'll be much more timely around my output soon!
@zhaokangxu7161
@zhaokangxu7161 7 месяцев назад
excellent and straightforward🎉
@RiskByNumbers
@RiskByNumbers 7 месяцев назад
Thank you! Trying my best to make sure next week's video is straightforward, too!
@charliehunter_
@charliehunter_ 4 месяца назад
Great Video! However, I am confused by what the output probability would be. In the video, would the 0.125168 be the probability of the tasks being completed in time or the probability that the deadline is missed? Thanks,
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Thanks, @charliehunter_! It was meant to be the probability the deadline would be missed. I summed up the number of instances that exceeded a threshold (in this case 9 hours) versus the total number of simulations. So, 12.5% is approximately the probability it takes us more than 9 hours (implying the deadline is not met). Thanks again!
@Tommybotham
@Tommybotham 2 месяца назад
Excellent video.
@RiskByNumbers
@RiskByNumbers 2 месяца назад
@Tommybotham: thank you!
@Tommybotham
@Tommybotham 2 месяца назад
@@RiskByNumbers I have a complex physics problem that I soon need to simulate, involving ionic particles (with a velocity distribution) that come in at different incident angles with some probability to neutralize on a surface AFTER which I'd then have to simulate the directions they go afterward. Monte Carlo came up and so I needed to brush up my knowledge and build some intituition to solve this problem. Your video greatly helped me get down some ideas on how to solve my problem :)
@RiskByNumbers
@RiskByNumbers 2 месяца назад
​@@Tommybotham thanks for the reply, and apologies for just getting back to you. I've really enjoyed learning about the different problems that others have analyzed/solved via Monte Carlo simulation. Glad the video could be of some utility, and I hope that you were able to solve it!
@user-kz9mb1km7p
@user-kz9mb1km7p 2 месяца назад
great!
@RiskByNumbers
@RiskByNumbers 2 месяца назад
Thank you!
@ambrosianas7505
@ambrosianas7505 6 месяцев назад
Please continue to post content. Subscribed!
@RiskByNumbers
@RiskByNumbers 6 месяцев назад
Thanks, @ambrosianas7505, for subscribing! I'll definitely continue to post content -- thanks again!
@kimsourtat601
@kimsourtat601 Месяц назад
Why not just find the middle of them. 1 to 5 = 3.5, and 2 to 6 = 4.5, total 8 hours. What do you think?
@RiskByNumbers
@RiskByNumbers Месяц назад
@kimsourtat601: great question! In this case, the expected value (the median happens to be the mean) of our two random variables is 3 and 4. The expected value of their summation is simply 3 + 4 = 7. However, ignoring the full distribution means that we cannot comment on other statistics (e.g., variance) nor explore, for example, the probability the total duration exceeds some threshold (in this case, 9 hours). Monte Carlo simulation, however, helps us do that without working out the solution analytically! I hope that helps.
@kimsourtat601
@kimsourtat601 Месяц назад
@@RiskByNumbers Thank you so much, the expected value is 7 hours (my bad is 8 hours). In this case he has 9 hours left to complete the task but there is 12.5% chance he could complete, if he take this task, he is unlikely to join his party. : (
@a1cswiz1611
@a1cswiz1611 Месяц назад
What doesn’t make any sense with this scenario is why would you randomize both A and B scenarios? How does finishing report A in 1 hour have the same equal chance of finishing it in 6 hours? Shouldn’t these hours have probabilities attached to them as well? Could you weight each hour into the randomizers?
@RiskByNumbers
@RiskByNumbers Месяц назад
@a1cswiz1611: great question (and apologies for the delayed response!). For each of these two reports, we are assuming that there is uncertainty around to complete them. For Report A, it is 1-5 hours and, for Report B, 2-6 hours. We can use our probability density function to define this uncertainty. You could also use a probability mass function, if we wanted to model time to complete each report as a discrete random variable. In NumPy, you can do this via np.random.choice(), and you can alter the probability masses as you see fit (i.e., each outcome does not need to have an equal probability of occurrence). The key aspect here is that the probability densities/masses should be representative of the uncertainty. If you believe certain times to completion have a higher relative likelihood, you should select a probability density/mass function representative of that situation. The nice aspect of Monte Carlo simulation is that it can adapt to alternative distributions. I hope that makes sense. Do not hesitate to follow up if you have any further questions. Omar
@Hassan_MMM
@Hassan_MMM 5 месяцев назад
❤ Plz. do consider an Experiment with Sub or Super martingale system in Future with Python
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
I was planning on covering Markov decision processes eventually, so this would be a great moment to discuss these topics. I sincerely appreciate the interest in the channel, the suggestion, and the patience in awaiting new content!
@danielzuzevich4161
@danielzuzevich4161 3 месяца назад
Great intro.
@RiskByNumbers
@RiskByNumbers 2 месяца назад
Thank you, @danielzuzevich4161! Much appreciated.
@MaximuskingTO
@MaximuskingTO 7 месяцев назад
What a great video! Can you do a video on hypothesis testing using Python?
@RiskByNumbers
@RiskByNumbers 7 месяцев назад
Thanks! That is definitely something I can introduce. The next few videos will focus on a few algorithms (e.g., dynamic programming, reinforcement learning), but the content afterwards is still up in the air. Thanks again for the comment and request.
@taylorolp8090
@taylorolp8090 4 месяца назад
Ok I could be wrong, but to find the percentage that you will miss the barbecue, you divided by sims which is 1mil. But the entire data set that is computed is 2*sims data points (A+B and both are 1 million points). So to find the actual chance you will miss the barbecue isn’t it actually closer to half of what you computed?
@RiskByNumbers
@RiskByNumbers 4 месяца назад
@taylorolp8090: really great question! The length of all 3 arrays is actually 1 million. As you mentioned, for "A" and "B" we have generated 1 million random values. When we implement "duration = A + B", we will actually create another array that is the same length as "A" and "B". The value for the first indexed value, duration[0], will be A[0] + B[0]. In fact, for any index value, i, duration[i] = A[i] + B[i]. In other words, we will have 1 million values, where each value is the sum of a random realization of A and another random realization of B. I hope that makes sense. Feel free to reply or follow up with me directly if anything is still ambiguous.
@JohnAbleton
@JohnAbleton 6 месяцев назад
u good thanks
@RiskByNumbers
@RiskByNumbers 6 месяцев назад
Thanks!
@TamaraKocic-hc2pw
@TamaraKocic-hc2pw 15 часов назад
Find the probability p(A) of the event A- that when throwing two "fair" dice, the sum of the numbers obtained was 7. Create a program for the simulation of n series (n>30) of 25 such switching and selection of balls, which at the output gives Xi - the number of realizations of event A in the i-th series (i=1,...,n). Consider the obtained sequence X1,...,Xn as a random sample from the Bin(25,p), 0
@raymondnepomuceno8815
@raymondnepomuceno8815 4 месяца назад
New sub right here
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Awesome @raymondnepomuceno8815! Welcome to the channel! Really appreciate the support.
@dalrax4
@dalrax4 3 месяца назад
You say that Monte Carlo analysis assumes a uniform distribution - meaning that all possibilities between the specified min and max values are equally likely to happen. But this is very rare, isn't it? If you know the shortest person is 3 feet tall and the tallest person is 8 feet tall and you programed an MCA to predict a stranger's height with this min/max range, wouldn't it be just as likely to predict a stranger is 3 feet tall as it would be to predict that they are 5'8"? You're going to be right MUCH more often if you guess a stranger is 5'8" than if they are 3 feet tall. Is this a weakness of MCA? Thanks. (Or wait...does lots of sampling within that range predict/simulate a normal distribution? But that's also a false assumption often, for example with stock market returns isn't it?)
@RiskByNumbers
@RiskByNumbers 3 месяца назад
@dalrax4: really great set of questions! Thanks as well for reaching out! For our Monte Carlo simulation, we could have actually assumed our distributions came from any available distribution to us. In this video, I used NumPy, and as you can see we actually have a broad set of distributions available to us for random sampling: numpy.org/doc/stable/reference/random/legacy.html. Your point highlights an important aspect of Monte Carlo simulation. Unless we specify our distributions (reasonably) correctly, we may be facing a case of creating a model that is 'garbage in, garbage out'. This point also highlights why, in many cases, an individual may be okay with just 1,000 Monte Carlo simulations. Given that we typically do not know our underlying distribution (it is estimated through various statistical means) for our inputs, we are oftentimes okay with an approximate estimate of the distribution for our response variable of interest (in this case, the total time to complete both reports). Your point about stock market returns is great (and relevant to the channel)! I'll actually be talking about the usefulness of natural logarithms for modeling financial data in the next video. I've recorded the audio and have made the animations -- I'm just finalizing the stitching of the two together.
@dalrax4
@dalrax4 3 месяца назад
@@RiskByNumbersThank you for clarifying that!
@MrMeltdown
@MrMeltdown 5 месяцев назад
Ask Todd what is his priority out of the two reports? He’s the boss and knows the answer to that question (even if you know the answer in your opinion). If he continues to say both then you say attempting both increases the risk that neither report will be finished so again, what is the priority? I’ve learnt over many years to not break your back for a boss. When I get treated by overly demanding bosses and customers is to hold back asking questions they have the answers to when time constraints start to cause problems you can raise the question giving many options and say you can’t complete it or even start working on it till the answer comes in. This does need working out before hand. But seems to be exactly what solicitors do in the uk when you chase them up….
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
@MrMeltdown: it's been pretty neat for me to see the range of responses to this video. Although the intended focus of this video was less so around the correct course of action for this situation, I enjoyed reading your response and your perspective. Personally, I have found that providing a rationale and acknowledging the other's perspective can go a long way in these situations. I find this even when I'm teaching. Explaining 'why' I've structured an assignment in a certain manner goes a long way in terms of student buy in. Similarly, acknowledging how student feedback from past years has informed certain choices in the current year gives students a sense of voice and acknowledgement. I think this extends to more traditional employer-employee relationships, too. Now, whether that actually happens is another story...
@davidclercrodriguez5801
@davidclercrodriguez5801 6 месяцев назад
Bro, amazing video!
@RiskByNumbers
@RiskByNumbers 6 месяцев назад
Thanks, @davidclercrodriguez5801! Really appreciate the kind words.
@stati5tik
@stati5tik 5 месяцев назад
It seems like what you do is calculate (or more specific approximate) the area under the curve with a limited amount of points. Let's say you have N points, and you want to use these N points to approximate the area under the curve. The monte carlo simulation now expects you to throws these N points "randomly" (uniformly) onto the curve increasing the chances to cover enough area for good approximation accuracy. _
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
@statistik4908 you may be interested (if you have not read it already) in McKay et al.'s 1979 paper that compares random sampling (as done in this video) vs. stratified sampling: www.jstor.org/stable/1268522. A really good read!
@SubZero101010
@SubZero101010 5 месяцев назад
I don't understand the benefit of initiating a random distribution here when the values between 1-5 hours and 2-6 hours should statistically occur with equal frequency. Why do I need the computer to generate random numbers when, in an infinite number of attempts, there should always be a 20% probability of each occurrence?
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
@SubZero101010: thanks for the great question. This particular problem was an instance where you could analytically solve for the distribution around the sum of these two random variables (per the discussion with @gokulr8755 in the comments). As mentioned by @andrewevanyshyn1709, seemingly 'simple' problems become quite complex quickly, and so this technique is a nice way to deal with this situation. Furthermore, this approach is a nice way to validate one's intuition and understanding of probability. For example, it is not necessarily obvious that the sum of a series of standard uniform distributions follows the Irwin-Hall distribution. Therefore, I sometimes like to use this technique as a way to validate that my derivations for simpler problems to ensure that they are sound.
@gokulr8755
@gokulr8755 6 месяцев назад
Question which bothered me for long which also suits this example: Say X and Y are random variables representing the time taken for each report, I'd have X+Y as the total time taken. Now, the distribution of X+Y can be evaluated by computing the convolution of X and Y and normalizing it. On doing so, will we get the same distribution as what the Monte Carlo simulation has given us? Does Monte Carlo perform essentially the same thing as convolutions? If it does, why is it better than convolutions? Eager to see your answer as I'm working on a project where I need to decide between using these two...(also do correct me if I went wrong somewhere)
@gokulr8755
@gokulr8755 6 месяцев назад
My project is to estimate the GPA distribution of my batch through the grading stats of each course that we get. The grade in each course being a random variable and the GPA being a weighted average. Was thinking of convolution approach to do this but now Monte Carlo seems computationally inexpensive compared to it(if it could work for this scenario that is)
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
Thanks, @gokulr8755, for this really fantastic question. You’ve made a really good point. In this problem, we are summing not just two random variables, but two independent random variables. The perfect case for convolutions to estimate the distribution of A + B. Here is then when I see Monte Carlo as being appropriate: 1. Fairly large, complex problems, where determining the underlying distribution for some application is difficult (or at least fairly involved) to compute. 2. Situations where you are satisfied with an “approximate” answer. From my own personal experience, the latter situation is what we typically find in practice. There are a couple of reasons. One of which is that, in the video problem, the true distributions of A and B are likely unknown. We are likely estimating those distributions from data, but in statistics the true distributions for A and B are not truly known. In addition, I should note that we may use Monte Carlo simulation to learn a “good” set of decision-rules. These days, I mainly work on reinforcement learning problems, where we will (1) simulate different realizations of the future; (2) make decisions in this simulation environment; (3) observe the reward of those decisions; and (4) update our decision-making policies based on the observed rewards. This did not really apply in this problem, as I was only interested in the distribution for a single decision (I.e., do the two reports), but Monte Carlo simulation is quite valuable in this context. I’ll plan on covering this in 3 videos. Lastly, I should note that, depending on the problem, you may be interested in other sampling methods such as Latin Hypercube sampling, which are generally more efficient and require less samples. Really great questions. I sincerely appreciate it.
@gokulr8755
@gokulr8755 5 месяцев назад
​@@RiskByNumbers Ah yes I'll look into that professor... It'd be great if you could bring out videos about RL, Markov chains, queuing, simulated annealing etc as these are some really cool topics of applied math in ML. Wanna get some ideas from you for good RL projects too in a video (which involve a bit of coding)...as an undergrad I(and many others) would need to show and test what they learned by doing projects
@aalb1970
@aalb1970 2 месяца назад
Invite Todd to the barbecue 😊
@RiskByNumbers
@RiskByNumbers 2 месяца назад
@aalb1970: on it! I'll invite him for this coming weekend.
@gumimi385
@gumimi385 6 месяцев назад
thank you
@RiskByNumbers
@RiskByNumbers 6 месяцев назад
Many thanks!
@dang4546
@dang4546 4 месяца назад
Had you started to work on the reports immediately instead of writing a program to inform you of your chances of making your party, you’d be done already 😊
@RiskByNumbers
@RiskByNumbers 4 месяца назад
😂 Funny enough, my spouse said roughly the same thing when I showed her the video, @dang4546.
@matejnovosad9152
@matejnovosad9152 2 месяца назад
Do what you are telling me is that I have been using MCS for years without knowing it
@RiskByNumbers
@RiskByNumbers 2 месяца назад
I enjoyed this note, @matejnovosad9152. If you don't mind me asking, for which applications/domain?
@matejnovosad9152
@matejnovosad9152 2 месяца назад
​@@RiskByNumbersmany things, mostly verifying my calculations. For example when I was a beginner and was not sure how to calculate the probability of one random variable from Normal dist being greater than another one from a different Normal dist. Or during covid instead of solving the diff equations to find sick people etc. I just simulated it using probabilities and many interations
@alperkaya8919
@alperkaya8919 4 месяца назад
So it means you will make it to the party with 88% of chance?
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Hi @alperkaya8919: correct! Perhaps more precisely: there is (approximately) a 12% chance that the 2 reports will take you more than 9 hours to complete. As the party is in 9 hours, there is a 1 - 0.12 = 88% chance that you will finish both reports prior to the party's start time. Thanks for engaging with this content.
@alperkaya8919
@alperkaya8919 4 месяца назад
@@RiskByNumbers Thank you very much for explaining!!!!!!
@riccardo-964
@riccardo-964 4 месяца назад
Only looking at those Uniform values I'd able to know with simple calculations the average amount of time to finish those reports... just saying, you used a nuclear bomb to crush a mosquito instead of crushing it with your feet...
@kdifiskeicis284kd72j
@kdifiskeicis284kd72j 4 месяца назад
bayesian statistic 101
@RiskByNumbers
@RiskByNumbers 4 месяца назад
Thanks, @kdifiskeicis284kd72j, for engaging with this content! I appreciate it.
@ValFolarin
@ValFolarin 6 месяцев назад
1. "You can pretty quickly estimate that there is a reasonable chance that you won't make it to the bbq in 9 hrs. Around 12-13 %". How is 12-13 % reasonable? That is very low. It sounds like you have quite a good chance to make it to the bbq no? 2. In most cases, the values will not be uniformly distributed obviously. Worst case scenarios are less likely to happen than non-worst case scenarios. How do you input this programmatically into matlab? can you make a video on that?
@RiskByNumbers
@RiskByNumbers 6 месяцев назад
Hi Val -- these are all excellent comments and points. With regards to your first comment: good point around the word choice "reasonable". It is making me think that I should put together a short video around risk and probabilities across contexts. As a simple example, engineering structures such as buildings and bridges are designed with a much lower probability of failure than 12-13%. A 12-13% probability of a failure would be considered quite high given the consequences of a failure could be catastrophic. Conversely, a 12-13% chance you are late to a meet-up would likely be viewed as more acceptable, in part because the consequences are much lower. As for your second comment: yes, I can definitely provide a tutorial on other distributions! I similarly received a good question in my video where I covered fitting data to a distribution in Python. I was asked how do we determine which distribution is "appropriate" (e.g., Gaussian, log-normal, etc.). So, I'll provide a tutorial on that topic soon. Feel free to reach out to me via email to continue the conversation!
@tito9641
@tito9641 6 месяцев назад
A video about this would be great too! Im also intrested in more of this kinda of content@@RiskByNumbers
@RiskByNumbers
@RiskByNumbers 6 месяцев назад
On it@@tito9641 !
@joacimjohnsson6704
@joacimjohnsson6704 5 месяцев назад
The result should be a normal dist. But it looks more like a triangular..... something is wrong in the plot.
@RiskByNumbers
@RiskByNumbers 5 месяцев назад
@joacimjohnsson6704: there is actually a nice analytical solution to this particular problem. I'd also suggest checking out the Irwin-Hall distribution, which is the distribution for the sum of "n" independent standard uniform random variables: en.wikipedia.org/wiki/Irwin-Hall_distribution. When "n" is large for the Irwin-Hall distribution, indeed it approximately follows a normal distribution. Conversely, if n = 2, we arrive at a probability density that resembles the one in the video. Based on this comment as well as one other in the thread, I am thinking that it may be worthwhile to step through convolutions on this channel. Thanks for the feedback, and definitely reach out to me directly to continue the conversation.
@seyproductions
@seyproductions Месяц назад
I didn't use numpy or matplotlib, but I was able to estimate it with just the random library (changing num_of_trials as I like): import random num_of_trials = 10000 time_limit = 9 num_of_successes = 0 num_of_failures = 0 for _ in range(num_of_trials): first_report = random.randint(1, 5) second_report = random.randint(2, 6) if first_report + second_report
@RiskByNumbers
@RiskByNumbers 15 дней назад
@seyproductions: awesome! As a small comment, you could actually use the random library to model the time to complete each report as both discrete (as you've done above with 'randint') or continuous! To do the latter, you could just change the following 2 lines of code to: first_report = random.random()*(5-1)+1 second_report = random.random()*(6-2)+2 This is inverse transform sampling, which forms the basis of other sampling methods. The idea is that the CDF for our uniform random variables (and any other random variable, for that matter) lies between 0 and 1. The CDF for a uniform distribution for the range between the minimum and maximum is: F(x) = (x-min)/(max-min). We can also rewrite this equation as: x = F(x)*(max-min)+min. Therefore, we use random.random() to generate a random CDF value between 0 and 1 (i.e., F(x)), and map that out to x. It is a pretty neat concept. Interestingly, the probabilities of completing the reports in 9 hours is extremely close for the discrete (88%) vs. continuous (87.5%) approaches (though just slightly different)! Finally, thanks for posting this comment -- really appreciate the effort and thought.
@scalex1882
@scalex1882 4 месяца назад
I don't really find this helpful. There is no explanation for what exactly a monte carlo simulation's defining idea is. Does the distribution have to be uniform? What if it's not? Based on the example, it seems to be adding two random variables and looking at their distribution, is that all? More (complex) examples would have helped too. This video left me with more questions than I came with.
@RiskByNumbers
@RiskByNumbers 4 месяца назад
@scalex1882: thanks for the comment. I appreciate that you took the time to (1) view this video; (2) provide feedback; and (3) list clarifications questions that you have after watching it. I'd be happy to expand on this topic with you, perhaps over email. Feel free to reach out at riskbynumbers@gmail.com.
@saurabhtiwari1764
@saurabhtiwari1764 5 месяцев назад
Something is deeply wrong with Todd
@tsunningwah3471
@tsunningwah3471 Месяц назад
s
@ravennsiregar
@ravennsiregar 3 месяца назад
Get Lost, Todd
@RiskByNumbers
@RiskByNumbers 3 месяца назад
😂😂😂
@Foollishgambino
@Foollishgambino 2 месяца назад
Yeah, Tod blows
@TheGooner-uh2jx
@TheGooner-uh2jx 18 дней назад
Don't we need to calculate standard deviation? For example we assume the tolerance is within 3 standard deviations, and divide each tolerance by 3 to calculate standard deviation of each report? So in this case the standard deviation of the first report would be 4/3 and the second report would also be 4/3. I've done Monte Carlo for mechanical quality engineering before using Minitab and we had to assume standard deviation for the process (3 sigma or 6 sigma). I've never done it in python looks pretty cool and I'm hoping to learn it thank for the video
@RiskByNumbers
@RiskByNumbers 15 дней назад
@TheGooner-uh2jx: these are really great points/questions. We actually don't need to define the standard deviation explicitly, as it is implicitly defined already via our distribution. What do I mean by that? The variance for a uniform distribution happens to be 1/12*(max-min)^2. Based on that, the variance for our problem is 16/12 = 4/3 for each report, and the standard deviation is therefore (4/3)^0.5. The above equation can be derived by knowing the following relationship: Var[X] = E[X^2] - E[X]^2. I'm thinking that this is of worthy discussion on the blog that I've just started to put together. Long story short, when you define any parametric distribution, the parameters selected define the variance implicitly. For certain distributions, such as the normal distribution, you need to define the standard deviation/variance given that it defines its probability density. Let me know if that helps, and feel free to reply with further questions!
@TheGooner-uh2jx
@TheGooner-uh2jx 15 дней назад
@@RiskByNumbers Thanks for the reply. I didn't realize your example was Uniform Distribution (didn't even know what that was until now). In my past experiences we mostly assumed Normal Distribution in Minitab. Excited to learn from your blog! I'm a mechanical engineer with very basic statistics background. I have a lot to learn!
Далее
Monte Carlo Simulation
10:06
Просмотров 1,4 млн
The better way to do statistics
17:25
Просмотров 152 тыс.
WHY DOES SHE HAVE A REWARD? #youtubecreatorawards
00:41
6. Monte Carlo Simulation
50:05
Просмотров 2 млн
Monte Carlo Methods : Data Science Basics
19:14
Просмотров 112 тыс.
Monte Carlo Simulation of a Stock Portfolio with Python
18:23
5 Good Python Habits
17:35
Просмотров 337 тыс.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Why Does Diffusion Work Better than Auto-Regression?
20:18