Coding Challenge #96: Visualizing the Digits of Pi

  Рет қаралды 105,966

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 115
@Naej7
@Naej7 6 жыл бұрын
One Coding Train video a day, keeps the depression away
@AkshayAradhya
@AkshayAradhya 6 жыл бұрын
Naej Choo-Chooo
@benciccarelli9870
@benciccarelli9870 6 жыл бұрын
Oui oui señor
@Naej7
@Naej7 6 жыл бұрын
Big Bang Ben Sí sí sir
@noosetime9423
@noosetime9423 6 жыл бұрын
it should crash in 4 hours and 37 minutes (if it's 60fps), because you're accessing i+1, and i+1 is gonna be 1 000 000, when the array goes only from 0 to 999 999
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
oops!
@ConorDrew
@ConorDrew 6 жыл бұрын
I noticed this when he wrote it, only because during one of my assignments indexOutofBounds caused me so many headaches as it’s a hidden gem of an error
@chitrachandrakar272
@chitrachandrakar272 4 жыл бұрын
@@TheCodingTrain whoops*
@timecubed
@timecubed 6 ай бұрын
​@@ConorDrew what did the assignment need you to do?
@ConorDrew
@ConorDrew 6 ай бұрын
@@timecubed it was 6 years ago, so I don’t really know, but a good takeaway from this is, things like this get learnt very quick once they catch you out, the best way to learn to program is by making and fixing mistakes, understanding the error message, calling your self an idiot as you done the same thing last week, and fix it.
@fabiomarques4110
@fabiomarques4110 6 жыл бұрын
how to draw the moon in a very strange way!
@wiscatbijles
@wiscatbijles 6 жыл бұрын
Just sick how much it resembles it.
@VenturiLife
@VenturiLife 6 жыл бұрын
*Mun
@Scouarn
@Scouarn 6 жыл бұрын
mün
@xemoable
@xemoable 6 жыл бұрын
*Maan
@ilyazakharov5862
@ilyazakharov5862 6 жыл бұрын
*Луна
@batfan1939
@batfan1939 6 жыл бұрын
You should assign each line a hue, and have the saturation go up by one each time that number appears. So, the circle would start off white, then become more colorful the longer the algorithm ran.
@leonardgrellier8790
@leonardgrellier8790 6 жыл бұрын
You're simply on the top of my 'most creative teachers' list, along with 3Blue1Brown
@Jabrils
@Jabrils 6 жыл бұрын
that last piece was mesmerizing
@leontius5502
@leontius5502 3 жыл бұрын
@Will Mathias Nice joke
@quinxx12
@quinxx12 3 жыл бұрын
Dude your hoodie is amazing! It's like the rainbow colors on the cords run right into the main body where the colors get mashed together and result in gray.
@rasyidcode3142
@rasyidcode3142 6 жыл бұрын
my new favorite channel for now.
@alexi1182
@alexi1182 6 жыл бұрын
Me? The viewer? A more talented creative person than you are? REALLY DAN?!! I've been trying to do this in p5 for the last 4 hours in which I accomplished absolutely nothing :)
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
you can do it, I believe in you!
@alexi1182
@alexi1182 6 жыл бұрын
I hope so my friend...
@elliey.x
@elliey.x 6 жыл бұрын
Yay! Finally! Thank you so much for this, you're a huge help to my beginning of learning code!
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Glad to hear!
@RicoBrassers
@RicoBrassers 6 жыл бұрын
As a hint: You don't have to split a string into a string array to get each character. Just iterate through each char in the string. Or, more suitable for the draw()-method, you could just use the charAt(int) method of a string object, to get the char at the specified position. example: int digit = Character.getNumericValue(digits.charAt(i));
@Naveication
@Naveication 6 жыл бұрын
RicoBrassers getNumericValue(char c) is way slower than accessing the index of a predefined integer array. While it wouldn't make much difference in this example, if he wanted to visualize the first trillion digits of pi and to speed up the process calculate a million on every drawcall then your approach would take a significantly longer amount of time. To parse a character in to an integer a million times per frame is just way slower than simply accessing a million integers from an array
@illustriouschin
@illustriouschin 6 жыл бұрын
Looks like the webs my pet spider makes after he's had too much meth.
@xetop
@xetop 6 жыл бұрын
15:38 Hahahaa I was just about to comment, that you made a pi based moon :D Nice video as always Mr Processing God !
@jasonwalker4610
@jasonwalker4610 6 жыл бұрын
This is in response to the rand pi calc using square circle method. You would get a more accurate pi calculation if you just made a nested x,y for loop, counted the amount that has rad less this x/2 from center of x,y then calculated ratio after nest is complete.
@Budzique
@Budzique 5 жыл бұрын
Added this just above line() for some random colors: stroke(255/10*(digit+1), 255/10*(nextDigit+1), 255/10*(digits[index+2]+1)); which will use the current, next and 3rd digits to create a random RGB.
@coding3070
@coding3070 6 жыл бұрын
I kind of want to print it out as a poster
@Xnoob545
@Xnoob545 3 жыл бұрын
15:19 looks like the moon
@ManosChalvatzopoulos
@ManosChalvatzopoulos 6 жыл бұрын
someone saw numberphile videos!
@AkshayAradhya
@AkshayAradhya 6 жыл бұрын
Manos Chalvatzopoulos Its just pi day related
@grev7794
@grev7794 6 жыл бұрын
PBJANDHIGHFIVES math concepts arent supposed to be short or meaningful :) i do learn about combinatorics, encryption, decryption,... from that channel.
@sigmareaver680
@sigmareaver680 6 жыл бұрын
yeah that legit looks like a moon.... idk.... jupiter or saturn
@JinTsen
@JinTsen 6 жыл бұрын
Shouldn't it be random in between -diff/2 and diff/2, so the digits won't overlap?
@AkshayAradhya
@AkshayAradhya 6 жыл бұрын
JinTsen Yes.
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
thanks for the correction! (the visualization here is ultimately meaningless, but hopefully it is helpful and can inspire viewers to make meaningful ones!)
@inperangua
@inperangua 6 жыл бұрын
JinTsen I'd even make a range a bit smaller, so the digits have visible space between them.
@inperangua
@inperangua 6 жыл бұрын
It's finally done Moon = Pi
@tobiass.8496
@tobiass.8496 6 жыл бұрын
Moon == Pi
@gautamsingh9175
@gautamsingh9175 6 жыл бұрын
this video is mind blowing but until now i am not good in coding so when i gain some knowledge then i can try it own my own you are great.
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Thank you!
@juangreen8194
@juangreen8194 6 жыл бұрын
Is a proven fact that the digits of pi are randomly distributed, so visualizing the digits of pi is equivalent to visualizing a randomly generated string of numbers.
@purrsum
@purrsum 4 жыл бұрын
15:25 for some reason it reminds me alot of the moon, right there.
@datejer
@datejer 6 жыл бұрын
These artists are polish lol, dont worry about mispronounceing their names, polish names are hard to pronounce if youre not polish, and no one i saw on the internet could pronounce polish words right, im polish too lol
@datejer
@datejer 6 жыл бұрын
Accualy only tge first one is polish lol
@bittim
@bittim 6 жыл бұрын
15:20 It somehow looks like the moon
@0xDEAD_Inside
@0xDEAD_Inside 5 жыл бұрын
If you squint your eyes to see the moon, you will see a smily.
@nemesmatyas
@nemesmatyas 6 жыл бұрын
We are cookin' here!
@cassandradawn780
@cassandradawn780 4 жыл бұрын
11:42 noice
@bryanmcconnahea9873
@bryanmcconnahea9873 6 жыл бұрын
Can anyone explain to me why the map function defining the angles use 10 instead of 9? It does in fact produce a uniformity of points around the circle by using 10 where using 9 pairs two points but in uniform manner in relation to other pairs... if that makes any sense. Anywya, I thought the map function was to convert the possible range of 0-9 to their equivalent of the range of 0 - 2pi...
@Truueh
@Truueh 6 жыл бұрын
You should marry Felicity Smoak from "The Green Arrow".
@vishalmishra1937
@vishalmishra1937 4 жыл бұрын
which technologies are used in this video to make visualization
@hermessantos181
@hermessantos181 6 жыл бұрын
The moon is PI :)
@codeman1021
@codeman1021 6 жыл бұрын
Sir pls start Neuro evolution 🙏🙏
@GOAFPilotChannel
@GOAFPilotChannel 6 жыл бұрын
you should make the stroke weight proportional to the count
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Nice idea!
@qwertzuiopqwertzuiop2107
@qwertzuiopqwertzuiop2107 6 жыл бұрын
I respect the effort you out intk making this videos and of course when making a video every single day not every single one of them will reach the bar, that you set quite high wuth your other videos. Buti was expecting you visualizing the patterns hidden in pi, as pi isnt a random number. But the results you got would have been the same if youve had used random numbers. At least as far i cant tell.. if not please correct me. Keep up the good work, most of your videos are great!
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
yes, this is right. this post offers more info: www.askamathematician.com/2009/11/since-pi-is-infinite-can-i-draw-any-random-number-sequence-and-be-certain-that-it-exists-somewhere-in-the-digits-of-pi/
@muhammadsaqlainishtiaq4467
@muhammadsaqlainishtiaq4467 6 жыл бұрын
Why processing if P5 is there or P5 if Processing is there. Do everything in 1.
@jakob7281
@jakob7281 6 жыл бұрын
Hello fellow programmers! int randomInt = (int)random(10); That line of code stores a random integer between 0 and 10 in randomInt. But here comes my question: Is every outcome equally likely? Because if typecasting to int is the same as it is in some other languages, wouldnt 10 be very unlikely? Sorry for asking here, didnt know where else to put it. Thanks in advance, Jakob
@portalsrule1239
@portalsrule1239 6 жыл бұрын
I think it should be equally likely. If you wanted to test it, you could keep track of how many times each digit got picked.
@sadhlife
@sadhlife 6 жыл бұрын
just run a code to count how many times each digit came up out of 10,000 total random draws and check how far each is from 1000
@jakob7281
@jakob7281 6 жыл бұрын
So, turns out the last number is not likely at all... As i expected, you can assume the chance of it occuring is 0: 0: 111098824 1: 111085682 2: 111127480 3: 111127772 4: 111120418 5: 111117453 6: 111122554 7: 111103272 8: 111096545 9: 0
@Schnorzel1337
@Schnorzel1337 6 жыл бұрын
I dont know what you did but random(10) gives the range [0,9] or for integers [0,10). Here is why:. random() gives a number between 0 inclusive and 1 exclusive. The function random(n) is equal to random() * n. So the range is [0,n). Tested it in Processing and Java.
@sadhlife
@sadhlife 6 жыл бұрын
Schnorzel1337 yeah.
@AbdulAziz-lf9lg
@AbdulAziz-lf9lg 6 жыл бұрын
Journey to the Moon with PI....😂
@empiricistsacademy7181
@empiricistsacademy7181 6 жыл бұрын
Recently found your channel and am a new subscriber. I want to make interactive educational web apps for teaching statistic concepts (for example to illustrate central limit theorem), which of your playlist series do you think would be relevant?
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
If you are totally new to programming try this one! kzbin.infoplaylists?view=50&shelf_id=14&sort=dd
@empiricistsacademy7181
@empiricistsacademy7181 6 жыл бұрын
Thank you very much for the reply, good think I clicked the bell icon. I am familiar with python programming for data analysis and implementing ML algorithms. But I don't know anything about web development, I heard django and flask in python can make web apps as well, so I was wondering whether I should learn that in python or java script. I will check out your java script playlist, thanks.
@JinTsen
@JinTsen 6 жыл бұрын
painful to be up to date with your videos, now I can only watch whenever you realease one ^^'
@gronkhfan011
@gronkhfan011 6 жыл бұрын
JinTsen
@arwa9385
@arwa9385 5 жыл бұрын
you r the cutest old man i've ever seen
@thederpyminecrafter77
@thederpyminecrafter77 6 жыл бұрын
what text editor are you using
@GenesisRussell-jt2rp
@GenesisRussell-jt2rp 6 жыл бұрын
what does PI sound like if smaller integers are lower pitched and larger integers are higher pitched
@GenesisRussell-jt2rp
@GenesisRussell-jt2rp 6 жыл бұрын
on second thought it probably sounds like white noise
@kniscior
@kniscior 6 жыл бұрын
By the way surname od this guy krzywinski is polish, u pronounce it like kshyvinsky
@meikusje
@meikusje 6 жыл бұрын
Do you think you could write a code to simulate the movements of a flock of starlings?
@aggressivegeek
@aggressivegeek 6 жыл бұрын
I think he has a video (series?) on PSO, a Swarm Intelligence algorithm based on patterns such as a flock of birds. Might be a bit more abstract from what you're asking for but certainly worth a look.
@waterfallbw
@waterfallbw 6 жыл бұрын
11:42 *420!!!!!*
@septicsounds3216
@septicsounds3216 6 жыл бұрын
Shouldn't the map-function for the angles only go from 0 to 9? (instead of 10)
@farhansyabibi170
@farhansyabibi170 6 жыл бұрын
Die Chaoten that would make 0 at 0, and 9 at two_pi, which is basically the same
@SelmanIsHere
@SelmanIsHere 5 жыл бұрын
The point is counted as a digit???
@Bloodwyn1756Swagger
@Bloodwyn1756Swagger 6 жыл бұрын
You could at least used a byte array ;)
@alanesamuel5167
@alanesamuel5167 6 жыл бұрын
Hi Dan Which Laptop do u use?
@danielsotojaimes3602
@danielsotojaimes3602 6 жыл бұрын
alane samuel .
@svanse45.56
@svanse45.56 6 жыл бұрын
Does he use Java?
@frogdeity
@frogdeity 6 жыл бұрын
NONAGON INFINITY 12:56
@samtheman448
@samtheman448 6 жыл бұрын
Just saw them live about a week ago... amazing experience.
@frogdeity
@frogdeity 6 жыл бұрын
They're coming to philly in June. I've never seen them live before and I am so hype.
@samtheman448
@samtheman448 6 жыл бұрын
Well you have much to look forward to! My personal fav from the gig was greenhouse heat death but it was all mindblowing.
@prabhjotsingh1255
@prabhjotsingh1255 6 жыл бұрын
51 viewer i watched it live
@theking23457
@theking23457 6 жыл бұрын
200 liker
@MsTwte
@MsTwte 6 жыл бұрын
what language i s this?
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Java with Processing: processing.org
@nietschecrossout550
@nietschecrossout550 6 жыл бұрын
101 Likes!
@LoganDark4357
@LoganDark4357 6 жыл бұрын
TAU
@Rightlime7923
@Rightlime7923 6 жыл бұрын
Coding train is million times better than numberphile ----
@Zakiyfarhanfuad
@Zakiyfarhanfuad 6 жыл бұрын
When i look at the clickbait, i thought it was a moon image
@razeev4685
@razeev4685 6 жыл бұрын
#first :)
@patricks5997
@patricks5997 6 жыл бұрын
Is it the regular java language?
@TheCodingTrain
@TheCodingTrain 6 жыл бұрын
Yes it is! (But using Processing: processing.org)
@patricks5997
@patricks5997 6 жыл бұрын
Thx man ! : )
Coding Challenge #97: The Book of Pi - Part 1
37:05
The Coding Train
Рет қаралды 51 М.
Coding Challenge #139: Calculating Digits of Pi with Collisions
31:42
The Coding Train
Рет қаралды 411 М.
Every parent is like this ❤️💚💚💜💙
00:10
Like Asiya
Рет қаралды 8 МЛН
The day of the sea 😂 #shorts by Leisi Crazy
00:22
Leisi Crazy
Рет қаралды 1,5 МЛН
What's The Longest Word You Can Write With Seven-Segment Displays?
8:56
Coding Challenge #28: Metaballs
23:48
The Coding Train
Рет қаралды 170 М.
How Many Digits of Pi Do We Really Need?
6:54
Real Engineering
Рет қаралды 654 М.
Coding Challenge #133: Times Tables Cardioid Visualization
17:21
The Coding Train
Рет қаралды 89 М.
Coding Challenge #89: Langton's Ant
20:58
The Coding Train
Рет қаралды 156 М.
What's so special about the Mandelbrot Set? - Numberphile
16:53
Numberphile
Рет қаралды 2,4 МЛН
Pi is Beautiful - Numberphile
8:24
Numberphile
Рет қаралды 1,8 МЛН
Coding Adventure: Boids
8:35
Sebastian Lague
Рет қаралды 1,5 МЛН
Every parent is like this ❤️💚💚💜💙
00:10
Like Asiya
Рет қаралды 8 МЛН