Coding Challenge 161: Estimating π from Random Numbers with Euclid's Algorithm

preview_player
Показать описание


🎬 Editing by Mathieu Blanchette

Links discussed in this video:

Other videos mentioned in this video:

Timestamps:
0:00 Happy Pi Day!
1:26 Explain! What does co-prime mean?
4:21 Explain! Euclid's Algorithm
8:40 Example! Finding the greatest common divisor.
9:55 Code! gcd() function with Euclid's Algorithm.
12:23 Code! Let's load the random digits.
14:39 Code! Let's use draw() for our loop.
16:13 Code! Co-prime or Co-factor?
17:44 Explain! How we are going to estimate π.
18:50 Code! Estimating π.
21:59 Code! Trying with digits of π.
22:54 Ideas! Thanks for watching!

#PiDay #PiDay2021
Рекомендации по теме
Комментарии
Автор

It would take longer to run but instead of increasing index by 2, just increase it by one. Currently the program checks gcd(a, b) then gcd(c, d) and so on. Increasing by 1 would check every consecutive pair, so gcd(a, b) then gcd(b, c) then gcd(c, d) and so on. You get almost twice as many pairs of numbers which is one of the two things that affects how accurate this is. The other thing being how big your random numbers are.

Another way to improve the estimation would be checking every number against every other number but that would take much much longer to run...

anthonycannet
Автор

I'm in love with this editing style

kabirbatra
Автор

If you choose substrings of 4 digits instead of 5 the estimation becomes 3.14159 🤯

tompov
Автор

You're not the only one who gets modulus/modulo mixed up. When I teach it, I just call it "mod" and avoid the whole problem ;-)

ncot_tech
Автор

The post-processing on this whole video is great XD love all the gags and running jokes

And what a fun program, too!

Mrjcowman
Автор

Using the randomness of the digits of pi to estimate the digits of pi. That is beautiful.

grumpyparsnip
Автор

"The Best Video of the Coding Train Ever"

wpersona
Автор

This morning the date on our clock showed us 3.14 and I immediately thought about you and your great videos.
Thanks for beeing who you are, wish you all the best!
Happy PiDay🍰🅿️ℹ️

gamesvrtech
Автор

Daniel you can use the series 3 + 4/(2*3*4) - 4/(4*5*6) + 4/(6*7*8)... to estimate PI! I did it in p5.js and got amazing results!

footballknight
Автор

I did this exact thing inspired by the exact same video a year ago!

adsoyad
Автор

Short function for GCD,

function GCD(a, b){
if(b == 1) return a;
return GCD(b, a%b);
}

gouravchouhan
Автор

i love all the new cute animations added to the videos

darthtorus
Автор

The video production is getting just better and better. Thanks. Great finale 🤯

jcponcemath
Автор

I haven't visiting this channel for a while, and now I found a superb edition!! It was magnificent.

xnick_uy
Автор

I'm a regular viewer, but I enjoyed this video even more. Love the animation at the beginning, the song, and the funny animated characters during the video. Great job :-)

CedLePingouin
Автор

10:39 - just min and max functions. Or sort the array and then pick in order.
Although, this version is good as well :)

Operaatoors
Автор

Fwiw, when you said recursion I smiled happily

fakenamerealguy
Автор

I would cache the results of the gcd call to prevent having to calculate the same gcd multiple times. this sounds crazy because you probably won't get many times of having the same 5 digit number, but the chance of a cache hit increases as it gets down to fewer digits. you can also do this cache check after the reordering of a and b to make sure it hit both (384, 78) and (78, 384)

samuelgunter
Автор

Yo, nice intro! I love the whole "world" that you built up to this channel

cortiazz
Автор

Hi Dan!!... i liked it!! especially the animations that you included in the video!!! plz keep those animations in the future videos as well!!.. Thanks a lot!

ramkumars