The Monte Carlo Method

  Рет қаралды 82,869

RandomMathsInc

RandomMathsInc

Күн бұрын

Пікірлер: 95
@malharjajoo7393
@malharjajoo7393 5 жыл бұрын
Damn, this was the clearest explanation I've seen on this stuff. Well done !
@Softdattel
@Softdattel Жыл бұрын
Very good introduction to monte carlo. You are doing a great job, clear concise, spiced with a little humor, no unrelated story telling! Keep it up. Thanks.
@jursamaj
@jursamaj Жыл бұрын
6:40 A better method: only generate your x samples. For each x, calculate the y (you're already doing this to decide if an x,y sample is inside or not, so this is the same efficiency). Add all of your y values to a floating point accumulator. At the end, divide the accumulated value by the number of samples to get an average height, and multiply by the width of the domain (10-1=9). You don't even need to know the maximum height this way. In practice, you wouldn't even use random x values, but equally spaced ones. In fact, I whipped this up in Python, and got the answer correct to about 1 part in 10^12, compared to yours at 1 part in 1^4.
@hansisbrucker813
@hansisbrucker813 9 ай бұрын
Do you happen to have the code somewhere. You made me really curious 🤓👍
@mateuszkujda3544
@mateuszkujda3544 4 жыл бұрын
I never write comments on yt, but I would like to thank the universe for bringing me to your channel and enjoying listening about the math and solving the problem. Good job man!
@francissydnor7891
@francissydnor7891 4 жыл бұрын
Absolutely incredible explanation. The world needs more people who can teach material like you can. Cheers!
@edgo6632
@edgo6632 2 ай бұрын
Best vid on Monte Carlo sim on KZbin. Hope this guy is making millions by now
@TrueTalenta
@TrueTalenta 2 жыл бұрын
Has anyone told you that you are just phenomenal and exceptional in your explanations! Great job!
@bigh8438
@bigh8438 3 жыл бұрын
This came up on my timeline. I use a representation of the Monto Carlo method for nuclear simulations at uni
@ear4funk814
@ear4funk814 4 жыл бұрын
Yep ... definitely clearest example of Monte Carlo Integration I've seen .... great job, and most appreciated!!!!
@johnburns9696
@johnburns9696 9 ай бұрын
I really enjoyed your explanation of using Monte Carlo simulation to solve an area under the curve problem. Cheers!
@jeshurunjohnson13
@jeshurunjohnson13 2 жыл бұрын
Thank you so much! I was stuck on a piece of code involving Monte Carlo simulations for days!
@rafshantik
@rafshantik 3 жыл бұрын
Such clear pronunciation of scientific terms. How do I talk like you? I always forget what I am going to say whenever giving presentation.
@pythonanimalia
@pythonanimalia 5 жыл бұрын
new to python. I like that the syntax suggestions pop up while you type. What are you using?
@adinathdesai6880
@adinathdesai6880 2 жыл бұрын
Thanks a lot, it really helps me to understand the concept and method of Monte Carlo method
@pacersgo
@pacersgo 3 жыл бұрын
In this example you don’t need to use MC. If you simply sample grids in very fine resolution, you can get the same results
@PintuBhattacharya-mp4mw
@PintuBhattacharya-mp4mw 3 жыл бұрын
Nicely explained. Requeting for an another video on integration of a 3-variable function.
@anandrai492
@anandrai492 2 жыл бұрын
Brilliant! So clear and concise, thank you so much.
@iidtxbc
@iidtxbc 2 жыл бұрын
Can you do "Quasi Monte Carlo"?
@peterchindove7146
@peterchindove7146 2 жыл бұрын
Totally enjoyed your presentation, kudos!
@rezakhalili5362
@rezakhalili5362 3 жыл бұрын
You're the best. It was so clear to me. unfortunately it wasn't what I wanted. But that made a good vision of this method
@stonecastle858
@stonecastle858 Жыл бұрын
Very well explained. Brilliant
@totimariageraci
@totimariageraci Жыл бұрын
Great clear explanation, thank you so much
@gutzimmumdo4910
@gutzimmumdo4910 Жыл бұрын
very clear explanation
@jagarali
@jagarali 6 жыл бұрын
This is a quite exhaustive explanation.. Thanks.
@renanlarrieu
@renanlarrieu 2 жыл бұрын
Clear and well done explanation. Thank you
@darcash1738
@darcash1738 Жыл бұрын
in python you should use a for loop, oh yeah plus for loops are faster
@KeesJansma7689
@KeesJansma7689 4 жыл бұрын
Thanks for this clear explanation! You're a funny cool dude as well.
@OfufualuaguAugustus
@OfufualuaguAugustus Жыл бұрын
Thanks for the video...I want to change the co so I can have several experiments and try them on a graph. How do I do so?
@spyhunter0066
@spyhunter0066 Жыл бұрын
excellent job, well done!
@Pradeepvlogs101
@Pradeepvlogs101 4 жыл бұрын
So clear explanation! Thanks
@IbnuNurHamzah
@IbnuNurHamzah 4 жыл бұрын
thanks for your explanation dude
@emrulhasan5646
@emrulhasan5646 3 жыл бұрын
Awesome explanation. Loved it. Thanks a lot!
@p.s.srinivas7696
@p.s.srinivas7696 4 жыл бұрын
Well explained. Concept became very clear.
@seandroid88
@seandroid88 4 жыл бұрын
Thanks this really helped understand the monte carlo question on my final
@boomsaway3
@boomsaway3 6 жыл бұрын
yoo thank you for this video, helped me so much. i dont get why university lectures always over complicate things so annoying haha
@donharrold1375
@donharrold1375 4 жыл бұрын
It’s pathetic, but they’d rather seem smart than educate you.
@LegitPizzza
@LegitPizzza 5 жыл бұрын
A very clear and concise video, thanks a lot for the explanation.
@austinjohn8713
@austinjohn8713 4 жыл бұрын
Thank you very much for making me understand what monte carlo methods are. The use of repeated random number generation combined with probability to provide numerical solutions to problems. Please you are calling the random generator twice in each loop iteration and therefore 2 million times by the time the loop is over . That is expensive. rather generate two sets of 1 million random numbers for x and y then traverse them in the loop. that way the random generator is called just twice
@Throwingness
@Throwingness 2 жыл бұрын
Magnificent explanation and demo. Did you know you can write 1000000 as 1_000_000 in python?
@entoris476
@entoris476 7 жыл бұрын
This method is obviously quite bad to use when the region probability is quite small, then you'd need to make the 'box' a bit more of an exotic shape to increase the probability...
@RandomMathsInc
@RandomMathsInc 7 жыл бұрын
Making the box more exotic-shaped, however, would mean it wouldn't be so simple to calculate the area of the box anymore.
@Santeca93re
@Santeca93re 5 жыл бұрын
Guernsey island
@Danny-ts7sc
@Danny-ts7sc 4 жыл бұрын
thank you, your explanation is way better than my teacher
@sirknightartorias68
@sirknightartorias68 2 жыл бұрын
Bro, u are AMAZING ⭐
@sergiovazquez2662
@sergiovazquez2662 4 жыл бұрын
Cheers man!! Great explanation for MC Method, and nice RP speaking!
@thehimalayan7041
@thehimalayan7041 6 жыл бұрын
very good, continue for next viedeo on mente carlo method .............I am waiting
@marceloescobar6389
@marceloescobar6389 3 жыл бұрын
Brilliant, absolutely brilliant
@dr.md.mehboobalam93
@dr.md.mehboobalam93 2 жыл бұрын
very nice video. I was thinking if we don't know the maximum value of the function then how do you call the random number for y?
@izzyt2286
@izzyt2286 2 жыл бұрын
THIS WAS AMAZING THANK YOU
@marcusseidowski3320
@marcusseidowski3320 4 жыл бұрын
Well Done and well explaned!!Amen!Can you do something concerning subset simulation or importance sampling?
@matteofalduto766
@matteofalduto766 3 жыл бұрын
The initial dart example is, in general, correct for a multivariable function. But the example of the logx/x is misleading, as you turn a single variable function with a single variable domain, into a 2 variable scenario. The correct way of explaining a Monte Carlo integration in 1D would be showing how the average of f(x) over a wide set of random x (in other words the average value of the graph) is equal to the area divided by the width of the domain... Said differently: the area of the graph over a given domain is the same as the area of a rectangle that is as wide as the domain, and as high as the average value of your function.
@peterchindove7146
@peterchindove7146 2 жыл бұрын
There are two variables x and y =f((x).
@matteofalduto766
@matteofalduto766 2 жыл бұрын
@@peterchindove7146 Well, y is a dependent variable, it doesn't count in this sense. You have only one independent variable over which you integrate, that's x. For example, a multivariable function would be something like z = f(x,y).
@peterchindove7146
@peterchindove7146 2 жыл бұрын
@@matteofalduto766 So ..the generated random number (r) is the other independent variable at x (let's call it r_x), within the domain...which you compare to lnx/x ( ie r_x >? lnx /x ). Am l helping?
@chdfnh
@chdfnh 4 жыл бұрын
Very good explanation. Thanks!
@skilz8098
@skilz8098 4 жыл бұрын
Very nice and simple explanation and demonstration through the use of python. Your algorithm worked quite nicely, however, the source code itself was written in a manner that was designed specifically for this problem... In other words, it's not exactly reusable. I've just written an integrator class in C++ that will calculate the integral of a function using Riemann Sums approximation. I was looking to extend my class to use other methods as well, Monte Carlo being one of them. I'm looking for a generic way to design the Monte Carlo method where the only information the integrator will have is the function of integration (its integrand), the limits of integration, and the step_size! The step_size within the context of Riemann Sums is the "width" of dx where that is defined by (upper - lower)/step_size where upper and lower are the bounds or limits of integration. Your video has given me some insights and it is still useful because I can always apply this technique to some Python source, but as for generating a generic reusable algorithm in C++... I still need to do some more research... Keep up the good work. Also, your video was a bit entertaining too!
@darcash1738
@darcash1738 Жыл бұрын
I just generalized it in Python. Wasn't bad at all: import numpy as np def func1(x): return np.log(x) / x def integrating_carlo(runs: int, function, x_bounds: tuple, y_bounds: tuple): in_area = 0 box_area = np.abs((x_bounds[1] - x_bounds[0]) * (y_bounds[1] - y_bounds[0])) for i in range(runs): x_cord = np.random.uniform(x_bounds[0], x_bounds[1]) y_cord = np.random.uniform(y_bounds[0], y_bounds[1]) if y_cord < function(x_cord): in_area += 1 return (in_area/runs) * box_area xb1 = (1, 10) yb1 = (0, 1/np.e) print(integrating_carlo(1000000, func1, xb1, yb1)) Ok, so the x bounds are simply the bounds of integration, I'm gonna have to come up with another function so I can find the min and max for the function tho so you don't have to manually put in the y-bounds. I know how the math works, idk how to code it at this point tho. Find all f'(x) = 0 and f''(x) and that point to see if min or max. Not sure how to code out derivatives ngl. In the end, I just checked min and max the normal way, tho it does compromise on some degree of accuracy
@jonavuka
@jonavuka 4 жыл бұрын
so what if you randomly generated a point twice or more than once for your simulation? Is that not considered or is that attributed to the error
@vishalsk8337
@vishalsk8337 3 жыл бұрын
Amazing work!
@vishalsaini5021
@vishalsaini5021 3 жыл бұрын
Greetings of the day sir...... Could you please make a video on how to consider uncertainty in big data such as solar radiation of 8760 hours with the help of Monte Carlo simulation
@rockandrolldevil665
@rockandrolldevil665 4 жыл бұрын
Thanks, that was an awesome class!
@donharrold1375
@donharrold1375 4 жыл бұрын
Seems like a massive amount of effort when a more straightforward numerical integration would be a lot quicker, i.e. divide the X axis into intervals (strips) between the limits of interest, calculate the Y value at the mid point of each interval and calculate the area of each rectangular strip under the curve. Sum the area of all the rectangles under the curve and hey presto you have solved the integral.
@1972hattrick
@1972hattrick 4 жыл бұрын
Simpsons rule is much better than your method
@lennywatchesstuff
@lennywatchesstuff 4 жыл бұрын
It's mostly used for higher dimensions because it is much faster. Imagine integrating an equation with multiple inputs, it will take forever to divide them into calculate the area for each inteval (you need (number of intevals)^(number of inputs) steps). For 10 variables, each one divide by say 10000, then you need (10000^10 steps). That's a lot of steps. Sure the error for monte carlos are higher than the midpoint method (O converges slower), but it is a very fast method that gives relatively decent accuracy.
@bishbash111gb
@bishbash111gb 4 жыл бұрын
This is the slowest of monte carlo integration techniques. You can use techniques such as importance sampling to increase the rate at which it converges
@PAA-ne3pc
@PAA-ne3pc 3 жыл бұрын
But how we are sure that the x_coord belong to the same point of y_coord that we are comparing e.g what if we compared a point on the function to another point under the function but with different x_coord
@natalie1997927
@natalie1997927 2 жыл бұрын
Hi! can you make a matlab video of how to use Monte Carlo method to calculate the volume of a cone inscribed in the unit cube(L=1)?
@FernandoRodriguez-ge2tg
@FernandoRodriguez-ge2tg 7 жыл бұрын
I know very basic java and I’m trying to tone out the python because it might confuse me. This video is fun
@michelebenedetti1335
@michelebenedetti1335 3 жыл бұрын
Hi, I want to apply the Montecarlo method to solve a double integral over a polygonal domain, is it possible?
@SathanaST
@SathanaST 3 жыл бұрын
Thanks 🙏 you are really cool!
@rafaelrodrigues4867
@rafaelrodrigues4867 4 жыл бұрын
Great video great explanation
@oneJL
@oneJL 3 жыл бұрын
could you plz explain more in details that why you come up with the hight of 1/e? Thanks in advance
@pacersgo
@pacersgo 3 жыл бұрын
It is the max y value
@Marco-mt8kw
@Marco-mt8kw 5 жыл бұрын
Great video, it was helpful
@plastiqueman
@plastiqueman 4 жыл бұрын
Thanks for the video, very helpful. I wrote the codes down exactly the same as you did but I'm getting an error "unsupported operand type(s) for *: 'NoneType' and 'float' "
@sirisaksirisak6981
@sirisaksirisak6981 4 жыл бұрын
In what situation MC doesn't work?How to reprove?
@pacersgo
@pacersgo 3 жыл бұрын
MC can be too slow for some applications. For example in radiotherapy, people try to calculate the distribution of the radiation dose to the patient body in real time. And until now it is still not possible with MC because of the long computational time.
@IK-dx6fr
@IK-dx6fr 2 ай бұрын
Great video
@chrischoir3594
@chrischoir3594 4 жыл бұрын
very nice, thanks
@henryadolfo
@henryadolfo 3 жыл бұрын
Well done !
@sakibhasan7857
@sakibhasan7857 3 жыл бұрын
pretty cool man❤
@____kklw7148
@____kklw7148 3 жыл бұрын
very clear
@ncirisaif9162
@ncirisaif9162 4 жыл бұрын
thank you
@theirishpizzaguy6663
@theirishpizzaguy6663 3 жыл бұрын
This might be a perfect explanation/tutorial.
@hsinghal1
@hsinghal1 2 жыл бұрын
ok
@staynjohnson4221
@staynjohnson4221 3 жыл бұрын
Unfortunately, there is no double-like button.
@tongxie7078
@tongxie7078 Жыл бұрын
This is the worst explanation I have seen on this stuff. Thank you so much!
@maxdefire
@maxdefire 4 жыл бұрын
Time solution obtain solution time time solution time obtain solution.
@michaelblankenau3129
@michaelblankenau3129 Жыл бұрын
I just keep hearing the same words over and over again
@_tube7362
@_tube7362 2 жыл бұрын
Dame good explanation, Can I get your email/Linkedin account?
Monte Carlo Simulation
10:06
MarbleScience
Рет қаралды 1,5 МЛН
Monte Carlo Integration In Python For Noobs
15:32
Andrew Dotson
Рет қаралды 155 М.
Monte Carlo Simulation with Card Games
8:21
Normalized Nerd
Рет қаралды 54 М.
Coding Challenge 176: Buffon's Needle
25:04
The Coding Train
Рет қаралды 102 М.
True Random Numbers - Computerphile
12:16
Computerphile
Рет қаралды 131 М.
Monte Carlo Simulation of a Stock Portfolio with Python
18:23
6. Monte Carlo Simulation
50:05
MIT OpenCourseWare
Рет қаралды 2,1 МЛН
Monte Carlo Geometry Processing
52:04
Keenan Crane
Рет қаралды 26 М.
S09.1 Buffon's Needle & Monte Carlo Simulation
16:12
MIT OpenCourseWare
Рет қаралды 39 М.
How to Generate Pseudorandom Numbers | Infinite Series
14:19
PBS Infinite Series
Рет қаралды 222 М.