Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#26 2012-09-06 14:50:10

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

I also use Python up


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#27 2013-02-23 18:32:34

LeoC123
Member
Registered: 2013-02-23
Posts: 3

Re: Python!

Yeah, I'm currently using Python because it is so much cleaner in style. It really just teaches you the concepts of computer science without really having to focus too much on syntax big_smile

Offline

#28 2013-02-24 02:17:19

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

I do not understand the program at podt #1


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#29 2013-02-24 05:22:15

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Hi;

He is making use of a geometric probability to evaluate pi.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#30 2013-02-24 07:26:10

ShivamS
Member
Registered: 2011-02-07
Posts: 3,453

Re: Python!

I do not tend to use Python at all anymore.

Online

#31 2013-02-24 13:49:16

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

Hi bobbym,

I don't understand at all.


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#32 2013-02-24 20:42:10

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Hi Agnishom;

You are picking random numbers in the range 0 - 1 for x and y, yes?

Do you follow so far, I can not upload a drawing so I will talk you through.

Last edited by bobbym (2013-02-24 21:30:01)


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#33 2013-02-25 00:23:37

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

Yes, two random numbers b/w 0 & 1
Then they are checking how many of them satisfy x^2 + y^2 < 1

So?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#34 2013-02-25 00:27:41

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

You can pair the x's and y's to make points. They would all be inside of a 1 x 1 rectangle in the first quadrant. Do you agree?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#35 2013-02-25 00:33:14

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

Ya.. All the points within a radius of 1 in the 1st quadrant


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#36 2013-02-25 00:36:46

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Not yet. You are jumping ahead. If we generate x's from 0 to 1 and y's from 0 to 1 and form ordered pairs and then plot them we would get something like this:

uKuqU.png

Last edited by bobbym (2013-02-25 00:37:05)


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#37 2013-02-25 00:39:11

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

And then we check how many of them are within a radius of 1 ?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#38 2013-02-25 00:43:11

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Yes, and form the ratio

MonteCarloPiMod_gr_25.gif

if you throw a lot of points it will approximate π/4.

This is called "Monte Carlo Simulation" and is a very powerful technique.

Last edited by bobbym (2013-02-25 00:57:14)


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#39 2013-02-25 02:01:23

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

Wonderful!
However that would hugely depend on the capability to generate random numbers

I think it would be a better idea to try this

...
for x in xrange(0.1, 1.0, 0.01):
   for y in xrange(0.1, 1.0, 0.01):
      .....

So that the points are not taken at random

Last edited by Agnishom (2013-02-25 02:05:29)


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#40 2013-02-25 04:26:22

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Hi;

The randomness is very important. It is the whole key to the algorithm.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#41 2013-02-25 07:12:26

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

Why??? What If we try all the possible points?


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#42 2013-02-25 07:15:59

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

It would take too many to try them all there are an infinite number. The random generator samples the points that your scheme might miss.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#43 2013-03-01 22:53:45

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

I will see which is better .... I shall do the experiment


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#44 2013-03-02 07:12:29

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

It is easy to design areas that a uniform spread of points such as yours might miss.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#45 2013-03-02 16:04:30

Agnishom
Real Member
From: The Complex Plane
Registered: 2011-01-29
Posts: 15,091
Website

Re: Python!

I did it.

You seem to be correct........


'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'Humanity is still kept intact. It remains within.' -Alokananda

Online

#46 2013-03-02 16:17:31

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Hi;

That was an interesting idea though.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#47 2013-03-02 23:02:16

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,860

Re: Python!

Hi bobbym

Is it just me or do the points in the plot in post #36 look a little denser near the line x=1/2?


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#48 2013-03-02 23:05:39

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Yes, that was when we could not upload any pictures and I had to use one from the internet. Unfortunately I chose one from a math forum. The guy who wrote the routine did a bad job and the points are not randomly placed.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

#49 2013-03-02 23:07:48

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 14,860

Re: Python!

Maybe they are randomly placed but with a different distribution.


“Here lies the reader who will never open this book. He is forever dead.

“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

Offline

#50 2013-03-02 23:09:04

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,777

Re: Python!

Nah, his method of generating random numbers was not good.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Online

Board footer

Powered by FluxBB