Explain the 30% ?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Explain the 30% ?!

Here's something I've observed while writing this code: https://code.sololearn.com/cF5g7V0m13ma/?ref=app Basically it checks if random boxes collide in 3D space. Although all points are randomly generated, the hit rate for a large enough group will always be around 30% ... Why is that? I have a clue, but lets hear what you think!

19th Jan 2018, 10:20 PM
Simon
Simon - avatar
4 Answers
+ 4
Given the average length of lines you are generating for your intersection boxes, I'm surprised it is that low. Having learned about AABB and your code in the last 30 minutes, if you had asked me to guess instead of given the number, I would have said something closer to 40%.
19th Jan 2018, 11:13 PM
John Wells
John Wells - avatar
+ 3
Your 1D to 4D are all lower than I expected. I was thinking 70% on 1D to 30% on 4D. Dropping 10% per added dimension. The odds of getting near 0 and near 256 on one of your lines with the second being more middle to my mind appears to be more than actual number.
20th Jan 2018, 3:23 AM
John Wells
John Wells - avatar
+ 2
If the random numbers are evenly distributed in the whole range, would it be safe to assume we have 50% chance of matching in 1D? Adding 2 more dimensions would reduce these chances proportionnally, so my guess is we should have 12.5% hits instead of 30%.
20th Jan 2018, 2:53 AM
Simon
Simon - avatar
+ 1
I experimented with the number of effective dimensions and got some interesting results: 1D: 66% Hit 2D: 40% Hit 3D: 30% Hit 4D: 20% Hit So it looks like each dimension has a consistant 2/3 chances of matching, which multiply if we combine them... Still not sure why, but I think that sorting the points adds some bias in the random set.
20th Jan 2018, 3:06 AM
Simon
Simon - avatar