The numerical simulation is NOT as easy as you think! - Average distance #2

  Рет қаралды 54,133

Mathemaniac

Mathemaniac

Күн бұрын

Continuing from part 1 (intro), we conduct a numerical simulation to calculate the average distance between two points in a unit disc. It turns out that the simulation is not as straightforward as you previously thought - it requires a bit of tweaking to sample points in the unit disc correctly.
There will be concepts including inverse transform sampling, t-distribution, and t-tests in the video, with inverse transform sampling having a more detailed explanation, because it is a considerably simpler concept which doesn't require too much prior knowledge. There is also a passing mention of the Box-Muller transform, which is used as an example of the pitfall of the inverse transform sampling - even though it works for all distributions, sometimes it isn't computationally efficient.
Even though this problem "highlights the unity and utility of the undergraduate mathematics curriculum" (from the paper below), I would assume you know nothing, so don't worry if you are not in university / have a degree in mathematics! If you are in college / university, hopefully the first few videos can be a nice revision and application of the concepts, and possibly a new perspective on the concepts.
The paper that I am following (very readable, for an undergraduate at least):
www.tandfonlin...
I do notice that MindYourDecisions made a similar video ( • VERY HARD Puzzle: What... ) a few years ago but for a unit square instead. I still make this video series because (1) the unit disc version is much harder to tackle in the sense that we are not even attempting to evaluate the integral, and (2) Presh's video seemed to pull pdf's and Jacobian out of nowhere, which might be confusing to people who have not gone to college to study mathematics, and genuinely quite a different level of difficulty from his other videos, so I am going to actually explain what those are.
Thank you so much for the overwhelming support for the video about the Dream Minecraft speedrun cheating drama! Hopefully this channel makes you like mathematics a bit more!
*CORRECTION*
6:06 I said F^(-1)(Y) less than r, but actually should be x, as said on the screen, because my script has been revised.
8:11 I mean sample size not the number of samples.
*SLIGHT CAVEAT*
Technically, we should consider F(x) to be the probability that X smaller than or equal to x, because this will be different if the distribution does not have a well-defined probability density. In those cases, the inverse of F is not as straightforward, but we can still define the inverse. See the inverse transform sampling method Wikipedia page below.
I might not have stressed enough, but it is shown on the screen, that in the general case, Y is a random number generator from 0 to 1. The range here is important because this will allow us to say that the probability that Y is less than or equal to F(x) is exactly F(x).
*RESOURCES FOR MORE DETAILS*
Numerical simulation data:
docs.google.co...
More about sampling methods described:
en.wikipedia.o...
en.wikipedia.o...
en.wikipedia.o... (an alternative algorithm for sampling a normally distributed variable)
Single-sample and unpaired two-sample t-tests:
• Test Statistics: Crash...
Single-sample t-test (more detailed):
• Statistics 101: Single...
(or consult any statistics textbook!)
Crash Course statistics playlist:
• Crash Course Statistic...
Other than commenting on the video, you are very welcome to fill in a Google form linked below, which helps me make better videos by catering for your math levels:
forms.gle/QJ29...
If you want to know more interesting Mathematics, stay tuned for the next video!
SUBSCRIBE and see you in the next video!
If you are wondering how I made all these videos, even though it is stylistically similar to 3Blue1Brown, I don't use his animation engine Manim, but I will probably reveal how I did it in a potential subscriber milestone, so do subscribe!
Social media:
Facebook: / mathemaniacyt
Instagram: / _mathemaniac_
Twitter: / mathemaniacyt
Patreon: / mathemaniac (support if you want to and can afford to!)
For my contact email, check my About page on a PC.
See you next time!

Пікірлер
@mathemaniac
@mathemaniac 4 жыл бұрын
Here is the spreadsheet for numerical simulation containing a lot of what I wanted to say but didn’t: shorturl.at/jtyMT This video takes me quite a while to make, just like the video about Dream (actually I probably spent more time on this video than that one), so do leave a like, subscribe with notifications on, and leave a comment! Upon reviewing this video, I might have gone too quickly at times, but the good thing about KZbin is that you can pause! I probably should have put in some places for you to catch a breath before moving on. It is very possible that there wouldn’t be a new video until late March. Hopefully it will be worth the wait!
@operationstarwars
@operationstarwars 4 жыл бұрын
Wait you uploaded this a minute ago but this comment is from 14 hours ago.. wut
@TheSpacePlaceYT
@TheSpacePlaceYT 4 жыл бұрын
​@@operationstarwars It's simple... it releases at a certain time.
@WinterFlare
@WinterFlare 4 жыл бұрын
@@operationstarwars Either he unlisted it or what Astronomer Josh Carter said.
@operationstarwars
@operationstarwars 4 жыл бұрын
thanks guys :)
@engr.rimarc.liguan1795
@engr.rimarc.liguan1795 3 жыл бұрын
Hi sir. I do not know but the link for spreadsheet in the comment section cannot be opened.
@omgitsliamg5334
@omgitsliamg5334 4 жыл бұрын
My man went from "statistics for dummies" to quadruple integrals like it's nothing
@T0NYD1CK
@T0NYD1CK 3 жыл бұрын
I have found maths books like that. You read the half page introduction on page 1 and think this book is going to be good. Then you turn over and it seems to be written in a foreign language!
@brendawilliams8062
@brendawilliams8062 Жыл бұрын
@@T0NYD1CK know personal math you can use and that mess becomes not as hard. 😂
@benYaakov
@benYaakov 4 жыл бұрын
This channel will be very famous later , because the man ( Trevor ) have done a lot of hard work and I can realise this by understanding his video creating efforts , knowledge perspective , research and hard work . Keep up the great content . Best 👍
@mathemaniac
@mathemaniac 4 жыл бұрын
Wow, thank you!
@dexter9594
@dexter9594 2 жыл бұрын
You was right
@dipi71
@dipi71 3 жыл бұрын
Please, for practical purposes, just generate cartesian coordinates in the square enclosing the unit circle, then do a fast distance test and throw the coordinate pair away if it's outside that unit circle. Efficient, evenly distributed, easy to implement and easy to reason about. Cheers!
@mathemaniac
@mathemaniac 3 жыл бұрын
Yes, that's another approach as given in the spreadsheet in the pinned comment, but the purpose of this video isn't just about solving this problem, but also introducing the statistical concepts of inverse transform sampling and t-test. While you're at it, what about in 3 dimensions, or higher? Can you see a pattern?
@ruicampos8631
@ruicampos8631 3 жыл бұрын
This is likely the most efficient approach too. That square root is expensive, might as well do the rejection sampling.
@T0NYD1CK
@T0NYD1CK 3 жыл бұрын
"just generate cartesian coordinates" That would have been my choice as well. Random angles, with any given resolution, will tend to bunch points around the centre as well. Just use a square and discard all the out-of-scope points.
@RhoFGC
@RhoFGC 2 жыл бұрын
Year late but that algorithm is bad for dimensions over 2 or 3. Wasted volume is a big deal and it scales pretty hard with dimension.
@dipi71
@dipi71 2 жыл бұрын
@@RhoFGC You're correct, my suggestion would be exceedingly wasteful for dimensions of 4 or greater. But in the Cartesian plane, it works well and is easy to understand. (Shortly after my initial comment, I managed to write a small Ruby script that managed to achieve even distribution in one radial swoop. But serveral months later, I now don't even know my own reasoning about that radar-like method anymore - should have commented my code better back then. Contrast and compare with my initial suggestion.)
@RedStinger_0
@RedStinger_0 4 жыл бұрын
I'm super interested in the big math involved! Can't wait for March, man!
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks for the appreciation! It is hopefully worth the wait.
@benYaakov
@benYaakov 4 жыл бұрын
Yes
@shambhav9534
@shambhav9534 4 жыл бұрын
My sleepy mind at night isn't capable of this, I'll come back at the morning with my full brain.
@whey3359
@whey3359 3 жыл бұрын
It still doesn’t work for me
@shambhav9534
@shambhav9534 3 жыл бұрын
​@@whey3359 It will, given you have more than 80IQ but as a non math nerd, it's not possible to get the whole video, it works, for the first few minutes, which is the main part, right after the morning walk with nice sleep and a completed sleep cycle(meaning naturally woken up), no alarms.
@BleachWizz
@BleachWizz 3 жыл бұрын
@@shambhav9534 I'm a math nerd and I need time to think abt it bro... this video honestly seems like it was made by an AI, a super-inteligent one who were already capable of understanding how teaching works. He's going methodically trough every bad explained parts of the subject, showing the reason why it's true instead of giving the end result as a rule to follow. True math is beautiful like this, you're just drawing what you're thinking. The rules are drawings of conclusions, showing conclusions doesn't teach why it works. Of course this conclusion is based surrounding this video only, no external examples.
@shambhav9534
@shambhav9534 3 жыл бұрын
@@BleachWizz This is so true, the video assumes you are thinking the same thing as Mathemaniac was thinking, which is almost never possible. You certainly need to pause and think in any maths video, that's normal.
@Jesse_Carl
@Jesse_Carl 4 жыл бұрын
I love the video! Im so mad at myself, because when thinking about this I totally did not realize the problem with just taking r to be a random value from 0 to 1. I am going to have to work on this problem more now. Fortunately I have just started a multivariable calculus class, so we will see if that gives me any insights that I did not have when the first video came out. I am so glad to have caught this channel early, because I feel like you have a bright future in the ultra-nerd math part of youtube. Probably just have to wait a few videos for all the people who were just interested in dream to unsubscribe though lol.
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks! Many people will make the same mistake as you did, including me when I first started to look at it, so don't be mad at yourself! If you started a multivariable class, the next video is probably of use (the Jacobian), but honestly the trick that will be revealed in the end of the video series is so clever that it is not really possible to have thought yourself, so it is entirely reasonable not to know how to solve this problem exactly.
@punditgi
@punditgi 3 жыл бұрын
A truly beautiful series. Bravo, sir!
@mathemaniac
@mathemaniac 3 жыл бұрын
Thanks so much for the appreciation!
@benYaakov
@benYaakov 4 жыл бұрын
Woah ! This made a quiet completion of concept that I watched before !
@ShefsofProblemSolving
@ShefsofProblemSolving 3 жыл бұрын
This is a phenomenal video. I've learned something new about sampling here !
@theaureliasys6362
@theaureliasys6362 2 жыл бұрын
My intuitive approach to generating dots would have been "generate two numbers between -1 and 1, then squre and add them. If the sum is greater than 1, repeat, if not, congrats, the point is inside the circle" Sure, this generates a couple of wrong points, but avoids crowding at the center.
@mathemaniac
@mathemaniac 2 жыл бұрын
Yes, that would work as well. However, in higher dimensions, you will realise that a lot of the sample point will get discarded. So for much higher dimensions, the answer you obtained from numerical simulation would be of lower accuracy if you choose this method of sampling, OR you will need to sample way more points.
@jceepf
@jceepf 2 жыл бұрын
The discrepancy is a version of Bertrand's paradox. I did it simply choosing four numbers between -1 and 1. If the four numbers are in the circle of radius 1, I compute the distance in cartesian coordinates. This clearly generates a uniform distribution inside the square. You lose in efficiency since you need to reject certain randomly generated pairs.
@pkacprzak
@pkacprzak 3 жыл бұрын
I find it much easier to generate a uniform point in a disk by generating uniform point in a square picking uniform x in [0,1] and uniform y in [0,1] independently and discard the points (x,y) that lie outside of the disc
@felicote
@felicote 3 жыл бұрын
It's more efficient too since computer the square root is much more expensive than sampling a few times.
@official-obama
@official-obama 2 жыл бұрын
yeah, and apparently someone made a video about why do it this way
@RexxSchneider
@RexxSchneider 2 жыл бұрын
@@felicote I'm afraid that it's a myth that square roots are much more expensive than sampling a few times. Modern processors have a microcode instruction 'FSQRT' that computes a square root in hardware using one instruction, not to mention parallel processing instruction extensions that can do multiple square roots simultaneously. The compiler will do the optimisations for you. With rejection sampling, the chance you get a valid point is π/4 (area of circle / area of square), so you're throwing away 21% of the points on average - and that's more than "sampling a few times". In practice, the time to run similar programs turns out to be about the same for either method.
@Qermaq
@Qermaq 3 жыл бұрын
I thought about polar coordinates, but noticed their bias toward central points, so what I did was this: generate random x1,y1 and x2,y2 pairs -1 to 1. Check each pair to see if the point is on the disc (x^2+y^2
@mathemaniac
@mathemaniac 3 жыл бұрын
Yep, that's another approach that is also mentioned in the spreadsheet in the pinned comment. Here is a challenge for you though: what about in 3 dimensions, or in higher dimensions? Using the same method, do you see a pattern in the average distance?
@ronaldjensen2948
@ronaldjensen2948 3 жыл бұрын
Using this method, the probability of getting a single point inside the circle is pi/4, and the probability of getting two points in a row inside the circle is (pi/4)**2 which is about 0.61685.
@mathscience9932
@mathscience9932 3 жыл бұрын
If you want to sample uniformly, do the following simple idea. Lets say R = 1 is the radius of the circle. To do random selection, you can just pair up circumferences that always add up to 2 pi R. So r = 0 pairs with r = R = 1, and r = x pairs up with r = R - x = 1 - x. Use a random number generator to produce a random number (x) in the range [0, R] = [0, 1] Once an x gets chosen, it means the r value to use will be either "r = x" or "r = (R - x) = (1 - x)" Now again use a random number generator to produce a random number (y) in the range [0, R] = [0, 1] if (y
@civilizati3
@civilizati3 Жыл бұрын
Wanted to share a quick trick that generalizes the problem of random sampling in an n-dimensional sphere. first generate n independent gaussian variables to make a vector x_n. Divide this vector by its magnitude. The result is a random sample of the surface of the n-sphere since the multivariate gaussian distribution is rotationally symmetric. Now apply the same trick and generate a uniform random variable, taking the n-th root. This is the same trick in the video but replacing r^2 with r^n.
@Antsabee
@Antsabee Жыл бұрын
man, love all your videos (I have seen so far), only issue with the video is a lack of "predicate" transcendentally down over the levels of explination. as an example... you are dealing with random sampling noise... but its pretty easy to understand that the mapping doesn't matter... its a common problem thats usually solved by calculating area... but then why use a random algorithm... I love the raw autistic awesomeness of what you do... its realy hard to balance what is needed vs what gets the sweet views... what you need to do is break down everyday things into amazing things... this references alot of tech and ideas in SEO... though completely seperate you can move between the forms of equations brilliantly, It helps to visualize all formulas in all thier forms... I havent seen anyone else really do that
@parkershaw8529
@parkershaw8529 3 жыл бұрын
Can I simply generate random points inside square between (-1, -1) to (1, 1) and throw away any points outside unit circle?
@mathemaniac
@mathemaniac 3 жыл бұрын
Yes indeed - and that is also the option I have said in the pinned comment of the spreadsheet.
@tedsheridan8725
@tedsheridan8725 3 жыл бұрын
I've been playing with the harmonic mean distance for a circle (and for a square) - basically the reciprocal of the average reciprocal distance - as it comes up when finding the total potential energy of a uniform charge distribution on a plate. Oddly enough you can find analytic solutions with basic (but tedious) calculus.
@superwarm626
@superwarm626 4 жыл бұрын
I love this channel if you didn't do dream I wouldn't have found your awesome channel
@mathemaniac
@mathemaniac 4 жыл бұрын
Can't understand why KZbin put this comment to "Held for review", so I didn't see it, but thanks so much! Glad you like the video!
@MuharremGorkem
@MuharremGorkem 3 жыл бұрын
I have a question... We can estimate the average distance as follows: Say the radius is 0...100. Pick 101 samples r=0...100. Similarly sample the angle. Say we sample it regularly 100 times as well. We calculate distance between (r1, A1) (r2, A2) for all our samples. But when we find a distance for (r1,..) - (r2,..) we think as follows. Since the circle with, for example r=100 should have contained twice the samples for r=50 (the circumference ratio), we apply weights to each point which is proportional to r. So r1 - r2 distance we multiply the calculated distance by w1 x w2 (r1 and r2's weights respectively). This approach nicely yields the correct result (a friend of mine did it using SAS). Question: Weighting argument is based on the assumption that a circle with r1 has MORE "ACTUAL" points than that of a circle with r2 where r1 > r2 (or vise versa). However we know that every circle has same number of points "actually". One is not greater or smaller than the other. They are infinite sets of same cardinality. Isn't this a PARADOX???
@RexxSchneider
@RexxSchneider 2 жыл бұрын
Sure, we know that ∞ / ∞ is an indefinite form, so we can't use a count of the number of points in a circle to determine the probability that a random point in the circle radius r1 also lies in the concentric circle radius r2 (taking r1 > r2). However, if we have a random sample of n points evenly distributed over the larger circle, we can count how many of those lie in the smaller one. It should not come as a surprise that the ratio of (points inside inner circle) : (points inside outer circle) is approximately the ratio of (the area of the inner circle) : (the area of the outer circle) if the points are _evenly_ distributed, as that is the definition of "evenly distributed". As the number of points n increases without bound, the ratio of the number of points will converge exactly to the ratio of the areas. The areas are finite quantities, of course, so we don't run into an indeterminate form when calculating probabilities.
@tobiasgorgen7592
@tobiasgorgen7592 4 жыл бұрын
2:21 Shots fired :D
@anthead7405
@anthead7405 2 жыл бұрын
Thanks
@toonplus5400
@toonplus5400 4 жыл бұрын
Hey I know that your channel is underated but it's ok mind your decision took 7 years and I promise u only need some time and please make more videos like this
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks for the appreciation!
@noemartinez3125
@noemartinez3125 4 жыл бұрын
Cool
@Krishnajha20101
@Krishnajha20101 4 жыл бұрын
Great video. Subbed.
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks so much!
@yashgupta597
@yashgupta597 3 жыл бұрын
Taking AP stat right now, the last part of the video had me pointing like that Leonardo DiCaprio meme
@mathemaniac
@mathemaniac 3 жыл бұрын
Haha :)
@JoeTaber
@JoeTaber 3 жыл бұрын
Use inverse transform sampling to convert computer generatable uniform distributions into the distribution suitable for a particular domain, in this case the radius component of polar coordinates.
@snurffff
@snurffff 3 жыл бұрын
For generating random points, why not just generate a point on a square and check if it is in the disc, if not then generate a new one. This would remove that bias towards the center of the disc, right?
@mathemaniac
@mathemaniac 3 жыл бұрын
Indeed, that's the approach said in the spreadsheet of the pinned comment!
@kylebowles9820
@kylebowles9820 2 жыл бұрын
As someone who's really into path tracing, I wish I had seen this earlier!
@benYaakov
@benYaakov 4 жыл бұрын
Big fan from india 😁Must reply 😁 , I revisited and watched your older videos Just asking for curiosity , how much of the maths did you learnt till your high school ? And as you replied some other comments in different videos , you'd always loved to study more than what called school prescribed syllabus maths , so can you suggest and tell me the books that you used to study till high school ( of near that ) . I am very very wondering about that vid that you did discovered your own catalans and your website as you told . Very smart and brilliant you are Reply and how old are you now 😁
@mathemaniac
@mathemaniac 4 жыл бұрын
I don't want to reveal my age :) I didn't learn any university-level maths while I was in high school - mostly "recreational level" maths, which is basically the first 20 or so videos on the channel. If you really want book recommendations, I did read Prime Obsession, Trigonometric Delights and e: the story of a number as more "recreational" side of things. Don't really spend too much time on the Catalan number video though - it is still unsolved. I would want it somehow to be solved, but it seems to be out of reach at the moment, but thanks so much for the support!
@benYaakov
@benYaakov 4 жыл бұрын
@@mathemaniac very thanks for sharing your experience and books , maybe I would be one day as intelligent as you are :) And i am glad to know that I don't have to start my maths journey by learning University level maths . Thanks very much , you are my maths hero😍
@benYaakov
@benYaakov 4 жыл бұрын
@@mathemaniac very thanks for suggestion , I found books very interesting especially the trigonometric delights . I wish to meet you in real . U You are my real hero in maths .
@conradmembrino8517
@conradmembrino8517 3 жыл бұрын
Here is another way to do this probability that I set up in excel. Consider unit circle (radius = 1) with center at the origin. Also consider a square with with sides of length 2 and "centered" at the origin. I will first calculate random points in this square as follows. Consider the first random point which I will call x1, y1. I want both x1 and y1 to be randomly distributed between -1 and +1. So I used "2*RAND() - 1" where RAND() calculated a random number between 0 and 1. So "2*RAND() - 1" generates a random number between be-1 and +1. So I calculated x1 and y1 using this. I then calculated x2 and y2 similarly and I calculated the distance, d, between (x1,y1) and (x2,y2) using d = sqrt((x1-x2)^2 + (y1-y2)^2). Now this is the distance between two random points in a square of side 2 centered ad the origin and not the unit circle. So what I did is I calculated if x1^2 + y1^2 < 1 and if x2^2 + y2^2 < 1. Both of these must be true for both (x1,y1 ) and (x2,y2) to both be in the unit circle. So I threw out (x1,y1) and (x2,y2) if either x1^2 + y1^2 > 1 or if x2^2 + y2^2 > 1 and then used the calculated "d's" only if both points were in the unit circle. I then copied this row of calculations down 1000 rows. I found on average around 60% of the pairs of random points were in the unit circle which were the pairs of points that I used the "d" for and calculated the average "d" for those points. The simulated answer came close the the calculated answer. For increased precision I hit F9 and recalculated new average "d"s for the average of around 600 points each time and then averaged these averages for 10 total sims or around 600 points each for a total of around 6000 sims and got an answer even closer to the the theoretical answer. This technique of drawing a rectangle around the curve you want the random points to be within works for other shapes other than a circle so for complicated shapes draw the rectangle around the area desired and calculate random points and distances. Then see if those points fall within the area described by the curve for the random shape and only use those punts that are within the area desired. This is a much simpler method to use for simulations especially for complicated shapes. I had originally used the "r, theta" method myself before I tried the surrounding the unit circle with a square of side 2 and got the same answer you did and could not figure out why the "r, theta" method did not work. Thanks for explaining.
@RexxSchneider
@RexxSchneider 2 жыл бұрын
it's "cheaper" algorithmically to generate (x1, y1) and immediately test if the point is valid (i.e. inside the circle), generating a new (x1, y1) if it isn't. Then do the same for (x2, y2). You then only calculate the distance for valid points and you don't have to throw away those cases where one point is valid but the other isn't. That results in an average rejection rate of about 21% ( = (4-π)/4 ). Sadly, it's not straightforward to implement on a spreadsheet, although it's very simple to accomplish as a program.
@YossiSirote
@YossiSirote 3 жыл бұрын
Could I have chosen x and y each uniformly distributed between -1 and 1 and taken x^2+y^2, and rejected any time that value is greater than zero. That should give me a uniform distribution. No?
@galzajc1257
@galzajc1257 3 жыл бұрын
Another way is to pick points in a square and check which one's are in the circle: n = 1 000 000; a = Table[ {T1, T2} = Table[2 RandomReal[] - 1, 2, 2]; If[Norm[T1] < 1 > Norm[T2], Norm[T2 - T1], Nothing], n]; Total[a]/Length[a]
@mathemaniac
@mathemaniac 3 жыл бұрын
Indeed, this is another approach which I have also said in the spreadsheet in the pinned comment. While you're at it, what about in three dimensions, or even higher? Can you see any pattern in the average distance you find?
@galzajc1257
@galzajc1257 3 жыл бұрын
@@mathemaniac Thanks. I see: ithis method doesn't work in higher dimensions well because the volume of unit sphere in n dimensions is $\left(\frac{\pi ^{n/2}}{\frac{n}{2}!} ight)^{\frac{1}{2} \left((-1)^n+1 ight)} \left(\frac{2^n \pi ^{\frac{n-1}{2}} \frac{n-1}{2}!}{n!} ight)^{\frac{1}{2} \left((-1)^{n+1}+1 ight)}$ and it quickly goes to 0 so I don't get points. Keep making great videos
@anmolabhayjain9721
@anmolabhayjain9721 4 жыл бұрын
Can I know how did you arrive at the correction term for the standard deviation? By the way awesome video.
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks for the appreciation! The correction term is known as Bessel's correction: en.m.wikipedia.org/wiki/Bessel%27s_correction This is a standard correction factor for estimating variance or standard deviation.
@averywilliams2140
@averywilliams2140 3 жыл бұрын
Very good video keep up the good work
@mathemaniac
@mathemaniac 3 жыл бұрын
Thanks!
@averageclassicalmusicenjoyer
@averageclassicalmusicenjoyer 11 ай бұрын
Hello! I saw that you released a video about jacobians after this, but there wasn’t anything specifically on this problem? Will part 4 also come out at some point?
@mathemaniac
@mathemaniac 11 ай бұрын
Look at the video after Jacobian - or look at the playlist for this video series.
@averageclassicalmusicenjoyer
@averageclassicalmusicenjoyer 11 ай бұрын
@@mathemaniac thank you!
@wata_tube585
@wata_tube585 4 жыл бұрын
8:11 I'm not statistician. Perhaps it is 'sample size' not 'number of samples'. ’number of samples' is literally the number of samples or groups.
@mathemaniac
@mathemaniac 4 жыл бұрын
Yes you are right, will edit this in the description.
@xavier9480
@xavier9480 4 жыл бұрын
I tried to work with out with python and I made the exact polar coordinates mistake
@mathemaniac
@mathemaniac 4 жыл бұрын
That's exactly why as said in the title, the numerical simulation is not as straightforward as you might have thought :)
@benYaakov
@benYaakov 4 жыл бұрын
@@mathemaniac yes , thanks for making vid and preventing me to do same mistake ( as I am bit lazy ) All the way , the one platform on youtube which makes me enjoy maths 👍
@cantcommute
@cantcommute 4 жыл бұрын
So good!
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks!
@terriplays1726
@terriplays1726 2 жыл бұрын
If you had given me this task: x = uniform random from [-1, 1] y = uniform random from [-1, 1] if x**2 + y**2 > 1: not in circle roll again I had a lot of exercises with non-cartesian coordinate systems in undergrad, but for real applications I never trust them.
@mathemaniac
@mathemaniac 2 жыл бұрын
If the number of dimensions increases, then this method of sampling will reject a lot of points, because the volume of a unit hypersphere will dramatically reduce in much higher dimensions, and you will need to sample much more points in order to find some inside the hypersphere. But sure, in 2 dimensions, this will be ok, because the probability that you need to reject is still reasonable.
@terriplays1726
@terriplays1726 2 жыл бұрын
​@@mathemaniac That is very true.
@culperat
@culperat 3 жыл бұрын
I don't feel like this should have been labeled as the numerical solution being difficult. It's more of an issue of setting up the probability distribution to be a uniform distribution not being (r,theta) ~ U[0,1] X U[-pi,pi], where the uniform distribution over a circle in polar coordinates is (r,theta) ~ sqrt(U[0,1]) X U[-pi,pi]. Which you did. I just don't think it's any issue with the numerical simulation, just an issue of the wrong problem setup. If however you setup the MC simulation for the uniform distribution and it was still considerably different, then there'd be an issue of the simulation. If it went wrong, then you'd have some sort of ill-conditioning. Which could be the case for extremely large sample size where the summation for averaging becomes large. For extremely large sample sizes, you instead work with the log values to reduce the float point error of the large summation. Still like the video none-the-less.
@ЗакировМарат-в5щ
@ЗакировМарат-в5щ 3 жыл бұрын
You chose a pretty complex way to make uniform density, I'd rather made square uniform and just accept within inner circle. But I agree that maybe for higher diminsins this method would be too wasteful.
@pedrokrause7553
@pedrokrause7553 4 жыл бұрын
I tried to do the numerical simulation myself before watching the video and, interestingly, I didn't have any problems with the distribution of points. My simulation in python 3.9 was able to generate the approximation of 0.9 in less than a minute, which is an error of ~0.6%.
@mathemaniac
@mathemaniac 4 жыл бұрын
You might have used a different method of sampling points, which might circumvent the point distribution issues.
@pedrokrause7553
@pedrokrause7553 4 жыл бұрын
I used the numpy module to generate random numbers
@datokvartskhava4711
@datokvartskhava4711 4 жыл бұрын
Nice video
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks!
@Mighty1Bob
@Mighty1Bob 4 жыл бұрын
nice vid mate
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks!
@benYaakov
@benYaakov 4 жыл бұрын
@@mathemaniac you deserve more friend 👍
@blakecoulter9443
@blakecoulter9443 4 жыл бұрын
Obligatory comment for the algorithm. Also thanks for the wonderful content!
@mathemaniac
@mathemaniac 4 жыл бұрын
Thanks so much!
@Algebrodadio
@Algebrodadio 3 жыл бұрын
This problem would have been trivial if you had used cartesian coordinates, sampled x and y uniformly on the interval [-1,1]x[-1,1] and then excluded the points (x,y) from your dataset which were outside the unit disk (e.g. where x^2 + y^2 > 1). Then your sample set of points would have been uniformly distributed across the disk.
@mathemaniac
@mathemaniac 3 жыл бұрын
Indeed, this is another approach which I have also said in the spreadsheet in the pinned comment. While you're at it, what about in three dimensions, or even higher? Can you see any pattern in the average distance you find?
@chiragraju821
@chiragraju821 3 жыл бұрын
Subbed
@mathemaniac
@mathemaniac 3 жыл бұрын
Thanks!
@raifegeozay687
@raifegeozay687 2 жыл бұрын
you can just pick a point with carteisan random x and y instead all of this. if the point is not in circle, try again until it is.
@therealtwistedvee
@therealtwistedvee 4 жыл бұрын
Hi bro! I'm new to this channel and I like Ur videos but the thing is when u say math my brain hurts:/ but anyway good job! Keep this up!!
@rifatzehra6546
@rifatzehra6546 4 жыл бұрын
Man , when you're gonna upload next ☹ I am eagerly waiting for next video And what software you use to make vids
@mathemaniac
@mathemaniac 4 жыл бұрын
The last part of the video already says roughly when I will upload the next video! See the description for the software question :)
@shambhav9534
@shambhav9534 4 жыл бұрын
1:20 Fancy way of saying Distance from centre and Angles.
@RagaarAshnod
@RagaarAshnod 3 жыл бұрын
Feel like there needs to be an intermediate video; something one step back to reduce brain goo.
@maxyazhbin826
@maxyazhbin826 3 жыл бұрын
please no music
@mathemaniac
@mathemaniac 3 жыл бұрын
What's wrong with the music?
@Leo-rh6rq
@Leo-rh6rq 3 жыл бұрын
@@mathemaniac i like it. Its soothing
@TheSpacePlaceYT
@TheSpacePlaceYT 4 жыл бұрын
37 views, 15 likes, and 0 comments
@kylecow1930
@kylecow1930 3 жыл бұрын
loop x1,y1 = random between -1 and 1 if dist(x1,y1,0,0) > 1 try again x2,y2 = random between -1 and 1 if dist(x2,y2,0,0) > 1 try again total += 1 totaldistance += dist(x1,y1,x2,y2) print(totaldistance/total) pardon my bad pseudo code im not a coder but like, it aint that bad
The weirdest paradox in statistics (and machine learning)
21:44
Mathemaniac
Рет қаралды 1 МЛН
Secret to sawing daughter in half
00:40
Justin Flom
Рет қаралды 33 МЛН
Bungee Jumping With Rope In Beautiful Place:Asmr Bungee Jumping
00:14
Bungee Jumping Park Official
Рет қаралды 17 МЛН
The biggest misconception about spin 1/2
34:06
Mathemaniac
Рет қаралды 96 М.
But How DO Fluid Simulations Work?
15:12
Gonkee
Рет қаралды 391 М.
Why π is in the normal distribution (beyond integral tricks)
24:46
3Blue1Brown
Рет қаралды 1,7 МЛН
A Swift Introduction to Geometric Algebra
44:23
sudgylacmoe
Рет қаралды 904 М.
Solved simply: the impossible integral
15:13
Mathemaniac
Рет қаралды 68 М.
What if we define 1/0 = ∞? | Möbius transformations visualized
25:27
An Exact Formula for the Primes: Willans' Formula
14:47
Eric Rowland
Рет қаралды 1,4 МЛН
Catalan Numbers - Numberphile
13:16
Numberphile
Рет қаралды 331 М.
The deeper meaning of matrix transpose
25:41
Mathemaniac
Рет қаралды 402 М.