Suggesting regarding improving accuracy of Circle.random_point() ?

22 views
Skip to first unread message

Amit Saha

unread,
May 3, 2014, 5:39:34 AM5/3/14
to sy...@googlegroups.com
Hello all,

Consider the program below which is an attempt to prove that the angle
inscribed at the center by any two points on a circle is always twice
the angle inscribed on the circumference:


from sympy import Circle, Point, Segment

def prove_theorem():

c = Point(0, 0)
c1 = Circle(c, 2)

p = c1.random_point()
q = c1.random_point()
r = c1.random_point()

pc = Segment(p, c)
qc = Segment(q, c)

pcq = pc.angle_between(qc)

pr = Segment(p, r)
qr = Segment(q, r)

prq = pr.angle_between(qr)

print((pcq/prq).evalf())

if __name__=='__main__':

for _ in range(100):
prove_theorem()



The result which should always be 2.00 theoretically ranges from
0.533910696827908 to 26.3044198350215.

The only source of this randomness seems to be the random_point()
method. But, is such a huge variance expected? Is there a way to
minimize this variance?

Thanks for any hints.

Best,
Amit.

Akshay

unread,
May 3, 2014, 10:00:23 AM5/3/14
to sy...@googlegroups.com


There is a way to reduce the variance, instead of evaluating at the end i.e     print((pcq/prq).evalf()) evaluate the random points in the beginning itself

p = c1.random_point().evalf()
q = c1.random_point().evalf()
r = c1.random_point().evalf()
Using the above method i get the values with a variance of 0.01 (1.99-2.01)

Amit Saha

unread,
May 3, 2014, 7:42:37 PM5/3/14
to sy...@googlegroups.com
Thanks for the tip. It seems to help the issue, but I am not able to
get low variance values as you report. I am getting variance as high
as 70, and 26 sometimes, etc.

Chris Smith

unread,
May 9, 2014, 12:57:31 PM5/9/14
to sy...@googlegroups.com
Make sure that the 3rd point is on the reflex side of the first angle, perhaps?
Reply all
Reply to author
Forward
0 new messages