|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#61
|
||||
|
||||
|
Re: Math Quiz 9
Quote:
|
|
#62
|
|||||
|
|||||
|
Re: Math Quiz 9
Quote:
Quote:
Quote:
If the working space were a cube, the small end of the distribution would start out with zero slope and a parabolic ramp of 4πr2. It would peak at a somewhat higher length (WAG of 0.6), have a similar change of curvature at length 1, and have an upper bound at √3. Spoiler for Did you notice?:
Last edited by GeeTwo : 20-07-2016 at 06:20. Reason: tweaks and spoiler wrapper - and no thirds |
|
#63
|
||||
|
||||
|
Re: Math Quiz 9
...
|
|
#64
|
||||
|
||||
|
Re: Math Quiz 9
Wrapping up some loose ends... Quote:
|
|
#65
|
||||
|
||||
|
Re: Math Quiz 9
If I could,
The reason I don't think it matters is that let's say you were to take one end point of any line very very very close to the edge. If you keep pushing it infinetly closer, it's essentially on the edge already (limits woo), so it doesn't matter. |
|
#66
|
|||||
|
|||||
|
Re: Math Quiz 9
Enough hours have passed:
Allowing the borders of the square does NOT matter. The likelihood of one of the endpoints falling in any given area within the permissible bounds is proportional to the area. The lines at the edge of the square have length but zero area, so even if they're allowed, the selected point will "never" be on the edge. A bit more formally, the chances of a point on an edge being chosen is infinitesimally small and (excepting something massively discontinuous like a delta function) does not affect the integration over the area. |
|
#67
|
||||
|
||||
|
Re: Math Quiz 9
You can generate uniformly distributed coordinates in a unit circle much more easily, actually (if you look at genPolyPt() in my code, I do exactly that). Just setting r to the square root of a random number will correct the unevenness of the distribution.
|
|
#68
|
||||
|
||||
|
Re: Math Quiz 9
What's the average length of all the line segments whose endpoints both lie on the unit square's perimeter? |
|
#69
|
|||||
|
|||||
|
Re: Math Quiz 9
Quote:
Code:
import numpy as np
iterations = 100000
avg = 0
for i in range(1000):
print(i)
for j in range(iterations):
perimeter = 4*np.random.rand(2)
if perimeter[0] < 1:
y1 = 0
x1 = perimeter[0]
elif perimeter [0] < 2:
y1 = perimeter[0] - 1
x1 = 1
elif perimeter[0] < 3:
y1 = 1
x1 = 3 - perimeter[0]
else:
y1 = 4 - perimeter[0]
x1 = 0
if perimeter[1] < 1:
y2 = 0
x2 = perimeter[1]
elif perimeter[1] < 2:
y2 = perimeter[1] - 1
x2 = 1
elif perimeter[1] < 3:
y2 = 1
x2 = 3 - perimeter[1]
else:
y2 = 4 - perimeter[1]
x2 = 0
length = np.sqrt((x1-x2)**2+(y1-y2)**2)
avg = (avg*j + length)/(j+1)
with open("9.1.txt", "a") as f:
f.write(str(avg)+'\n')
Last edited by z_beeblebrox : 21-07-2016 at 11:44. |
|
#70
|
|||||
|
|||||
|
Re: Math Quiz 9
Ah okay that makes sense. Thanks!
|
|
#71
|
|||||
|
|||||
|
Re: Math Quiz 9
Quote:
|
|
#72
|
||||
|
||||
|
Re: Math Quiz 9
Close enough
Two billion samples yields a value about 0.003% less than that. Plotting the average vs the number of samples gives a rough view of when you've reached the point of diminishing returns. Note that this problem can be easily solved using all three methods discussed in this thread: Monte Carlo simulation Numerical Integration Symbolic Integration Standard deviation is not so meaningful when the distribution looks this this. |
|
#73
|
|||||
|
|||||
|
Re: Math Quiz 9
Quote:
Quote:
Edit: By decay, I mean that the population curve is concave up as it approaches zero, not necessarily an exponential decay. Last edited by GeeTwo : 22-07-2016 at 14:18. |
|
#74
|
||||
|
||||
|
Re: Math Quiz 9
5000 samples of sample size 1,000,000. Mean of the sample means = 0.735089 Standard Error of the Mean = 0.000361 |
|
#75
|
|||||
|
|||||
|
Re: Math Quiz 9
OK, another follow-on challenge (cleared with Ether):
What is the average length of all the line segments which can be drawn within the unit circle (1 unit in radius, 2 units in diameter)? Reps for both the first numeric (good to 1 part per million) and first closed form solution. Edit: Of course, you must show your work in either case! Last edited by GeeTwo : 25-07-2016 at 14:05. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|