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

You are not logged in.

#1 2014-01-24 13:46:01

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

Mathematica - Counting Balls

http://reference.wolfram.com/mathematic … Image.html

Can I count the number of balls in my monte carlo simulation model that I posted in the other thread?


'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

Offline

#2 2014-01-24 14:02:51

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Hi;

Post processing will not beat pre-processing in this case.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#3 2014-01-24 14:28:03

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

Re: Mathematica - Counting Balls

I beg your pardon?


'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

Offline

#4 2014-01-24 14:48:40

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Sorry, I forgot that in your case this does not apply.

Enter this:

Dimensions[circles]


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#5 2014-01-24 15:02:49

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

Re: Mathematica - Counting Balls

In a new notebook?

That returns the same thing because circles is not defined


'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

Offline

#6 2014-01-24 15:05:47

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

Re: Mathematica - Counting Balls

The problem is to count the number of circles inside the quadrant and outside the quadrant in this picture?

z1f6.jpg


'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

Offline

#7 2014-01-24 15:07:31

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Each help page is a notebook. Most of the time you can run the cells as if you had entered them. You can also add your own commands.

But to make life easier for you right now copy the commands to a new notebook and run them. Tell me when you have completed that task.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#8 2014-01-24 15:16:35

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

Re: Mathematica - Counting Balls

In[3]:= Dimensions[circles]

Out[3]= {}

'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

Offline

#9 2014-01-24 15:18:34

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Did you copy the help commands and run them?


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#10 2014-01-24 15:22:00

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

Re: Mathematica - Counting Balls

What commands are you talking about?


'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

Offline

#11 2014-01-24 15:28:53

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

The OP has posted a link. In[58] and In[59] are called cell labels. They are the names of the cells that have the commands that generated Out[61]. Highlight In[58] and In[59] and copy them to a new notebook.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#12 2014-01-25 00:29:54

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

Re: Mathematica - Counting Balls

I've already tried doing it and it works. But why do you want me to do that?


'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

Offline

#13 2014-01-25 00:32:22

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Did you run

Dimensions[circles]


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#14 2014-01-25 01:00:57

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

Re: Mathematica - Counting Balls

After that? No


'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

Offline

#15 2014-01-25 01:04:55

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Can I count the number of balls in my monte carlo simulation model that I posted in the other thread?

If you run Dimensions[circles] after running the other two that question will be answered.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#16 2014-01-25 14:47:50

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

Re: Mathematica - Counting Balls

Using which picture? That of the cells or my model?


'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

Offline

#17 2014-01-25 18:12:12

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

There are 2 cells that need to run. They are in M's help. Copy and paste them. Then run them. Then you run the command I posted to you.
From there we can try to answer the OP's question.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#18 2014-01-25 22:51:24

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 3,848

Re: Mathematica - Counting Balls

Hi,

I'm really only watching this thread because although the topic's too advanced for me I'm interested in the idea of M counting shapes in an image...just out of curiosity.

Here's an image of what I did in M.

View Image: Counting balls in M.jpg

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#19 2014-01-25 23:20:38

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Hi;

Did you see the result of the Dimensions command? Notice the first number which is 31.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#20 2014-01-25 23:31:38

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 3,848

Re: Mathematica - Counting Balls

Hi Bobby,

Yes, I did see the result of the Dimensions command, and noticed that the first number (31) is the count of the red circles. What does the '2' represent?


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#21 2014-01-25 23:41:03

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 3,848

Re: Mathematica - Counting Balls

This is the result I got when replacing the OP's 'drawing' with an image of it taken from the OP's page.

I suppose the reduction in the sharpness of the image accounts for the discrepancies in circle identification when compared with the original. The count being the same would be a fluke.

View Image: Counting balls in M-2a.jpg

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#22 2014-01-26 01:28:41

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Hi;

The two tells us it is an array of 31 elements of 2 each.

I would say the 31 is a coincidence in the smeared out drawing. But it is not in the sharp image.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

#23 2014-01-26 14:05:49

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

Re: Mathematica - Counting Balls

Who is OP?


'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

Offline

#24 2014-01-26 15:20:02

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 3,848

Re: Mathematica - Counting Balls

Hi Agnishom

Who is OP?

I don't know...was just following bobbym's lead in post #11.

bobbym wrote:

I would say the 31 is a coincidence in the smeared out drawing. But it is not in the sharp image.

phrontister wrote:

I suppose the reduction in the sharpness of the image accounts for the discrepancies in circle identification when compared with the original. The count being the same would be a fluke.

I increased the size of the OP's original image with ImageResize[i, {420, 280}] - those are the output dimensions - and copied the resized image with a screen capture using SnagIt...which came up nice and sharp. I replaced the code's image with SnagIt's, quit M, reran M and got exactly the same result as the original.

This was just to test the program on an actual imported image.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#25 2014-01-26 20:55:44

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 86,776

Re: Mathematica - Counting Balls

Hi;

OP means original poster.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Offline

Board footer

Powered by FluxBB