Thread: Math Quiz 9
View Single Post
  #36   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