Go to Post You miss 100% of the shots you don't take. - AdamHeard [more]
Home
Go Back   Chief Delphi > Other > Math and Science
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 16-07-2016, 17:20
Aren Siekmeier's Avatar
Aren Siekmeier Aren Siekmeier is offline
on walkabout
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: 대한민국
Posts: 735
Aren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Hitchhiker 42 View Post
What is a Monte Carlo simulation?
https://en.wikipedia.org/wiki/Monte_Carlo_method

Randomly sample the set of all line segments, and find the mean length of only the segments in the sample (a finite number chosen to suit your computational resources, rather than the uncountably infinite number in the entire set). If the sampling matches the probability distribution/weighting of the set, then the law of large numbers says your mean will approach the true mean as sample size increases.
Reply With Quote
  #17   Spotlight this post!  
Unread 16-07-2016, 17:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Hitchhiker 42 View Post
What is a Monte Carlo simulation?
Aren beat me to it.

One-line AWK script:

BEGIN{for(i=1;i<100000;i++){sum+=sqrt((rand()-rand())^2+(rand()-rand())^2);}print sum/i;}



Last edited by Ether : 16-07-2016 at 17:29.
Reply With Quote
  #18   Spotlight this post!  
Unread 16-07-2016, 21:33
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 502
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: Math Quiz 9

I ran the Monte Carlo thing in a python script and the answers, each run with 1,000,000 trials, were all around 0.333. I'm gonna keep thinking, though, how to get an exact answer.

Quote:
Originally Posted by Ether View Post
Your script has an error.

Compare it to the one-line AWK script I posted.



EDIT: I found the error - the value comes out to 0.521
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award

Last edited by Hitchhiker 42 : 16-07-2016 at 22:01.
Reply With Quote
  #19   Spotlight this post!  
Unread 16-07-2016, 21:38
FiMFanatic FiMFanatic is offline
Registered User
no team
 
Join Date: Apr 2016
Location: Michigan
Posts: 49
FiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud of
Re: Math Quiz 9

I am thinking the answer is a number that is very small (close to 0), as you can draw a ton more 0.000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 01 lines than you can 1 inch (or larger on a diagonal) lines.
Reply With Quote
  #20   Spotlight this post!  
Unread 16-07-2016, 21:43
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 502
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: Math Quiz 9

Quote:
Originally Posted by FiMFanatic View Post
I am thinking the answer is a number that is very small (close to 0), as you can draw a ton more 0.000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 01 lines than you can 1 inch (or larger on a diagonal) lines.
Yet if you look at the Monte Carlo simulation, it looks closer to 0.521"
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award

Last edited by Hitchhiker 42 : 16-07-2016 at 22:01.
Reply With Quote
  #21   Spotlight this post!  
Unread 16-07-2016, 21:47
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Hitchhiker 42 View Post
I ran the Monte Carlo thing in a python script and the answers, each run with 1,000,000 trials, were all around 0.333

Your script has an error.

Compare it to the one-line AWK script I posted.


Reply With Quote
  #22   Spotlight this post!  
Unread 16-07-2016, 22:00
z_beeblebrox's Avatar
z_beeblebrox z_beeblebrox is offline
Custom User Title
AKA: Cal
FRC #4183 (Bit Buckets)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cambridge MA
Posts: 811
z_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond repute
Re: Math Quiz 9

My simple Python Monte Carlo script gave me an average of 0.521408 (or 0.52141 rounded to 5 digits) in ~5e9 iterations (10 miles of hiking worth).

Code is below:
Code:
import numpy as np

iterations = 10000000

avg = 0

for i in range(100000):
    for i in range(iterations):
        pos = np.random.rand(4)
        length = np.sqrt((pos[0]-pos[1])**2+(pos[2]-pos[3])**2)
        avg = (avg*i + length)/(i+1)
    with open("test.txt", "a") as f:
        f.write(str(avg)+'\n')

Code:
import numpy as np

f = np.loadtxt('test.txt')
print(np.average(f))
print(len(f))
I split it into two scripts just so I could stop the computation whenever without altering the result.

Edit: Reps to whoever finds the bug in my code and explains what it does.
__________________
2012 Utah Regional Rookie All-Star
2013 Phoenix Regional Judge's Award for "design process and prototyping"
2014 Hub City Regional Quality Award, Arizona Regional Excellence in Engineering Award
2015 Arizona East Regional Creativity Award, Winner
2016 Arizona North Regional Finalist, Arizona West Excellence in Engineering Award, Finalist

Last edited by z_beeblebrox : 16-07-2016 at 22:57. Reason: New challenge
Reply With Quote
  #23   Spotlight this post!  
Unread 16-07-2016, 22:16
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by z_beeblebrox View Post
0.52141 rounded to 5 digits
That is the correct answer. Reps to you


Reply With Quote
  #24   Spotlight this post!  
Unread 16-07-2016, 22:20
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Ether View Post
That is the correct answer. Reps to you

Now, how would you get the correct answer accurate to, let's say, 8 decimal places?


Reply With Quote
  #25   Spotlight this post!  
Unread 16-07-2016, 22:32
FiMFanatic FiMFanatic is offline
Registered User
no team
 
Join Date: Apr 2016
Location: Michigan
Posts: 49
FiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud of
Re: Math Quiz 9

Makes no logical sense unless the question is improperly worded or bounded. You can fit an infinite number of lines in the box, and fact is, more lines closer to 0 in length fit in the box than lines averaging 0.52xxxx
Reply With Quote
  #26   Spotlight this post!  
Unread 16-07-2016, 22:35
z_beeblebrox's Avatar
z_beeblebrox z_beeblebrox is offline
Custom User Title
AKA: Cal
FRC #4183 (Bit Buckets)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cambridge MA
Posts: 811
z_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by FiMFanatic View Post
Makes no logical sense unless the question is improperly worded or bounded. You can fit an infinite number of lines in the box, and fact is, more lines closer to 0 in length fit in the box than lines averaging 0.52xxxx
I think the problem is more "Choose two random points inside by a 1" square and measure the distance between them. Repeat infinitely. What's the average of those measurements?"
__________________
2012 Utah Regional Rookie All-Star
2013 Phoenix Regional Judge's Award for "design process and prototyping"
2014 Hub City Regional Quality Award, Arizona Regional Excellence in Engineering Award
2015 Arizona East Regional Creativity Award, Winner
2016 Arizona North Regional Finalist, Arizona West Excellence in Engineering Award, Finalist
Reply With Quote
  #27   Spotlight this post!  
Unread 16-07-2016, 22:40
FiMFanatic FiMFanatic is offline
Registered User
no team
 
Join Date: Apr 2016
Location: Michigan
Posts: 49
FiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud of
Re: Math Quiz 9

Quote:
Originally Posted by z_beeblebrox View Post
I think the problem is more "Choose two random points inside by a 1" square and measure the distance between them. Repeat infinitely. What's the average of those measurements?"
I agree then - your answer would make sense if that were the question. However, it was:

What's the average length of all the line segments which can be drawn inside a 1 inch square?
Reply With Quote
  #28   Spotlight this post!  
Unread 16-07-2016, 22:43
z_beeblebrox's Avatar
z_beeblebrox z_beeblebrox is offline
Custom User Title
AKA: Cal
FRC #4183 (Bit Buckets)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cambridge MA
Posts: 811
z_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by FiMFanatic View Post
I agree then - your answer would make sense if that were the question. However, it was:

What's the average length of all the line segments which can be drawn inside a 1 inch square?
If the problem is interpreted as you describe (What is the average length of all the line segments that could be packed into a 1" square at once without overlapping?), there would be no meaningful answer, since infinite line segments of any length l < sqrt(2)" could be fit within the square, as line segments have no thickness thus can be packed infinitely densely.
__________________
2012 Utah Regional Rookie All-Star
2013 Phoenix Regional Judge's Award for "design process and prototyping"
2014 Hub City Regional Quality Award, Arizona Regional Excellence in Engineering Award
2015 Arizona East Regional Creativity Award, Winner
2016 Arizona North Regional Finalist, Arizona West Excellence in Engineering Award, Finalist

Last edited by z_beeblebrox : 16-07-2016 at 22:49. Reason: grammar
Reply With Quote
  #29   Spotlight this post!  
Unread 16-07-2016, 22:48
FiMFanatic FiMFanatic is offline
Registered User
no team
 
Join Date: Apr 2016
Location: Michigan
Posts: 49
FiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud ofFiMFanatic has much to be proud of
Re: Math Quiz 9

Exactly - hence why people struggled to answer I think......
Reply With Quote
  #30   Spotlight this post!  
Unread 17-07-2016, 02:34
Aren Siekmeier's Avatar
Aren Siekmeier Aren Siekmeier is offline
on walkabout
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: 대한민국
Posts: 735
Aren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond repute
Re: Math Quiz 9

Precisely ln(1+sqrt(2))/3 + sqrt(2)/15 + 2/15

Or approximately 0.52140543316
Rounded to 8 digits: 0.52140543
Rounded to 5 digits: 0.52141

A fun exercise in every integration tool I've ever learned, plus a cool rationalization trick I wasn't familiar with.

The computation took a bit to hash through some arithmetic errors and one silly differential error (chain rule!). In practice you probably wouldn't bother to do this (or use a symbolic manipulation tool like Mathematica - this is how I checked my work), and sometimes there is no closed form for the integral. To get 8 digits simply run a larger Monte Carlo simulation (a couple lines of code instead of several pages of derivation). In the end we are always limited to some finite number of digits, so numerical methods win out.
Attached Files
File Type: pdf mathquiz9.pdf (134.2 KB, 65 views)
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 05:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi