Go to Post Adversity should be seen as a challenge and not as an obstacle. :D - waialua359 [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
  #1   Spotlight this post!  
Unread 22-08-2016, 18:59
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 Ether View Post
[b]OK I'm going to drop a bombshell here.

The correct answer to the OP, as worded, is 0.33634

...

Sampling segments by choosing the segment endpoint coordinates from a random uniform distribution does not match the probability density of the segment lengths in the infinite set.


It's hard to disagree with your first figure.

If you can switch the order of integration and then integrate the pdf over theta, then you should have a pdf for L only. I'm trying to wrap my head around why that pdf for L should be different than the one effected by a uniform weighting of dx1dx2dy1dy2 differential elements. The concept in my head is that there's no invertible change of variables with which to set up that translation. The transformation from coordinates to length is not injective, so the Jacobian in the change of variables is zero: hard to divide by, conceivably giving the ratio between our answers in some sort of limit. Or from another view the four-dimensional differential element is of measure zero within the one-dimensional one, reflected by a pdf for the coordinates that is somehow undefined or not finite??

I'm very curious if there is an appropriate pdf for the coordinate approach that would give this result. Or is it just the wrong way to look at the problem?

This seems to boil down to the difference between:
[1] Average distance between all unordered pairs of points
[2] Average length of all line segments
But what's the difference?

Last edited by Aren Siekmeier : 22-08-2016 at 19:04.
Reply With Quote
  #2   Spotlight this post!  
Unread 22-08-2016, 19:24
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
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 Aren Siekmeier View Post
This seems to boil down to the difference between:
[1] Average distance between all unordered pairs of points
[2] Average length of all line segments
But what's the difference?
The difference is in how you choose samples.

If you want the average distance between all unordered pairs of points, then you choose coordinates of pairs of points from a uniform random distribution, and compute the corresponding distance.

If you want the average length of all segments, you randomly choose a segment length, a segment orientation, and the coordinates of the center of the segment. Then you discard any chosen segments which are not inside the square. If you run a Monte Carlo sim of that, you'll get 0.3363

...and you'll get a pdf of L only, if you make a histogram of the data and adjust it to have an area of 1.





Reply With Quote
  #3   Spotlight this post!  
Unread 22-08-2016, 19:32
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 Ether View Post
The difference is in how you choose samples.

If you want the average distance between all unordered pairs of points, then you choose coordinates of pairs of points from a uniform random distribution, and compute the corresponding distance.

If you want the average length of all segments, you randomly choose a segment length, a segment orientation, and the coordinates of the center of the segment. Then you discard any chosen segments which are not inside the square. If you run a Monte Carlo sim of that, you'll get 0.3363

...and you'll get a pdf of L only, if you make a histogram of the data and adjust it to have an area of 1.





How practical of you

I'd like to think it's possible to parametrize the choice of line segment by end points. Curious about the difference between that and the problem (simply choosing uniformly distributed end points) that we wrote 94 posts about. Obviously the end points of all line segments are not uniformly distributed in the square.

I've got an idea for finding just what their distribution is that I might get to if ever get unswamped this week.
Reply With Quote
  #4   Spotlight this post!  
Unread 22-08-2016, 20:20
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
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


FWIW: seglen pdf for L theta x y versus x1 y1 x2 y2 sampling

Attached Thumbnails
Click image for larger version

Name:	seglen pdf for L theta x y sampling.png
Views:	5
Size:	18.8 KB
ID:	20995  Click image for larger version

Name:	seglen pdf for x1 y1 x2 y2 sampling.png
Views:	4
Size:	21.1 KB
ID:	20996  
Reply With Quote
  #5   Spotlight this post!  
Unread 22-08-2016, 20:35
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

Still stuck in my old ways aren't I.

Here's the distribution of endpoints using your sampling procedure.
https://plot.ly/~compwiztobe/9/

Code:
from random import random
from math import pi,cos,sin,sqrt
import numpy

def randseg():
	hl=random()/sqrt(2)
	th=random()*pi
	cx=random()
	cy=random()
	return [cx-hl*cos(th),cx+hl*cos(th),cy-hl*sin(th),cy+hl*sin(th)]

def inbox(seg):
	return(all([x>=0 and x<=1 for x in seg]))

def go(n):
	l=[]
	for i in range(n):
		x=randseg()
		if inbox(x):
			l.append(x)
	return(l)

def pts(l):
	p=[]
	for x in l:
		p.append([x[0],x[2]])
		p.append([x[1],x[3]])
	return(p)

data=pts(go(1000000))

#then bin and plot 2d histrogram with plotly API
Curious about an analytical form, but this at least shows the idea. The way we solved the problem before assumed this plot was all one color.
Reply With Quote
  #6   Spotlight this post!  
Unread 22-08-2016, 22:16
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,531
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Ether View Post
The difference is in how you choose samples.

If you want the average distance between all unordered pairs of points, then you choose coordinates of pairs of points from a uniform random distribution, and compute the corresponding distance.

If you want the average length of all segments, you randomly choose a segment length, a segment orientation, and the coordinates of the center of the segment. Then you discard any chosen segments which are not inside the square. If you run a Monte Carlo sim of that, you'll get 0.3363
I believe this is fallacious, in particular that for a given center point and two different segment lengths, there are the same number of segments. For the center point at (0.5, 0.5) and length 0.2, the candidate segments are the diameters of a circle of radius 0.1. For the center point at (0.5, 0.5) and length 1.0, the candidate segments are the diameters of a circle of radius 0.5. As there are five times as many points on the large circle to serve as either end of a diameter, it logically has five times as many diameters.

When you take this into account, the integral in the denominator becomes:

0π/401/cosθ (1- Lcosθ) (1- Lsinθ) L dL dθ =
0π/401/cosθ L - L2cosθ - L2sinθ + L3cosθsinθ dL dθ =
0π/4[ L2/2 - L3cosθ/3 - L3sinθ/3 + L4cosθsinθ/4 ]01/cosθ dθ =
0π/4sec2θ/2 - sec2θ/3 - sec2θtanθ/3 + sec2θtanθ/4 dθ =
0π/4sec2θ/6 - sec2θtanθ/12 dθ =
[tanθ/6 - tan2θ/24 ]0π/4 =
[1/6 - 0 - 1/24 + 0 ] = 1/8
If you then integrate the adjusted calculation using 1/8 for the deominator, just substitute r for L and α for θ, and you will have the third equation of my most recent post in this thread.

Addition: Also, the idea of the average segment in a square of size 1 being within 1% of the average segment on any of its sides is .. counter-intuitive, to say the least.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 22-08-2016 at 22:24.
Reply With Quote
  #7   Spotlight this post!  
Unread 22-08-2016, 22:37
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
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


For the center point at (0.1, 0.1) and length 0.2, the candidate segments are the diameters of a circle of radius 0.1. For the center point at (0.1, 0.1) and length 1.0, the number of candidate segments is zero.


Reply With Quote
  #8   Spotlight this post!  
Unread 23-08-2016, 00:22
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,531
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Ether View Post

For the center point at (0.1, 0.1) and length 0.2, the candidate segments are the diameters of a circle of radius 0.1. For the center point at (0.1, 0.1) and length 1.0, the number of candidate segments is zero.
Though it is not relevant, there are plenty of candidates, though none are selected.

Here's another case which more clearly shows the fallacy.
  • What is the average distance from the origin to a point in the unit square?
  • What is the average length of the radials from the origin to points in the first quadrant of a circle of radius √2?

Solving the first question in Cartesian coordinates, we find the answer to be (√2 + ln(1+√2))/3 = 0.765...

Solving the second question using the logic used by Ether to count radials, the answer comes out to √2/2 = 0.707..

As the quadrant of the large circle includes all the same points as the unit square plus others which area all farther away than either average, there is a fallacy here somewhere.

By weighting the density by r, the second question is properly answered 2√2//3 = .942...

Addition:
To more fully explore this point, I propose the following questions:
  • What is the average length of a segment in a rectangle 1 unit wide and 0.5 units high?
  • What is the average length of a segment in a rectangle 1 unit wide and 0.1 units high?
  • What is the average length of a segment in a rectangle 1 unit wide and infinitesimally high? (that is, the limit as height goes to zero from above)
  • How does that compare to the average length of a line segment within the line segment from 0 to 1?
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 23-08-2016 at 08:32. Reason: Addition: on
Reply With Quote
  #9   Spotlight this post!  
Unread 23-08-2016, 10:50
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
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


Question for Gus:

What is the average length of all the vertical line segments in a unit circle?

Reply With Quote
  #10   Spotlight this post!  
Unread 23-08-2016, 11:10
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: 459
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 Ether View Post
Question for Gus:

What is the average length of all the vertical line segments in a unit circle?
If I may,
Spoiler for Thoughts:

My approach would be to take the top semicircle (equation y=sqrt(1-x^2)) and find the average value of those vertical segments by integrating from -1 to 1 and dividing the area by the base (-1 to 1 is 2). Then, you could multiply by 2 for a full circle. Answer comes out to pi/2.

Work attached below.

EDIT: Gosh darn I only did those with both points touching the the edges. Lemme work on that.
Attached Files
File Type: docx math.docx (16.7 KB, 2 views)
__________________



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

Last edited by Hitchhiker 42 : 23-08-2016 at 11:27.
Reply With Quote
  #11   Spotlight this post!  
Unread 23-08-2016, 11:55
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,531
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Hitchhiker 42 View Post
EDIT: Gosh darn I only did those with both points touching the the edges. Lemme work on that.
Also, don't forget to weight by the number of segments - the x coordinates near the center contain more segments than those near the left and right edges.

In any case, to answer Ether's question, the short answer is "not the same as the average length of segments within a small angle (e.g. 1 second of arc) of vertical within the circle." We've got another build session this evening getting ready for Red Stick Rumble, so I don't know how much I'll get done on this tonight.

Addition:
Hitchhiker, thanks for answering a different question. While walking across the street to get lunch, I think I put some nails in this coffin. Consider these two questions:
  • What is the average length of a vertical chord of the unit circle?
  • What is the average length of a chord of the unit circle which passes through (-1,0)?

You answered the first - the area of the unit circle divided by its width: pi/2.
I answered the second in my paper a score or so posts back (first problem), in a form that is not incompatible with Ether's method, provided angle is checked before length: 4/pi.
If you answer the second using Ether's method but checking length first, then picking one of two possible angles, you will get an average value of 1.

Completing reducto ad absurdum is left to the reader - back to work!

Quote:
Originally Posted by Ether View Post
I just can't trip you up, can I
Well, not that easily.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 23-08-2016 at 12:30.
Reply With Quote
  #12   Spotlight this post!  
Unread 23-08-2016, 12:13
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
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 GeeTwo View Post
In any case, to answer Ether's question, the short answer is "not the same as the average length of segments within a small angle (e.g. 1 second of arc) of vertical within the circle."
I just can't trip you up, can I


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 10:45.

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