# Math question.

Discussion in 'Community Discussion' started by StephenCampbell, Mar 8, 2011.

1. ### StephenCampbell macrumors 65816

Joined:
Sep 21, 2009
#1
I was just having a debate with my cousin about the odds of winning the lottery.. well, not really a debate about the odds, the odds are the odds, but a debate about whether it's worth it to play.

He argued that it's like having a computer randomly create and assign a certain number of bytes to make up a photo, hoping that it'll be a photo of my face. I felt that this would be much less likely than winning the lottery, so I did some calculations, and I'm Pretty sure that if we're talking about the Mega Millions, which has a 1 in 175 million chance of winning the jackpot, that this theoretical photo would need to be only 4.12 bytes in size before the odds of a random assignment of bits reaches lottery odds.

Because the odds of the first bit being what it's supposed to be are 50%, and it's x 50% when you add the next one, and so on and so forth, then starting with 50 and dividing it by two 647,760 times (for an 82 KB / 80,970 byte / 647,760 bit photo), would get you the percentage chance you have of the machine randomly creating that photo, right?

So, since 1 in 175 million can also be expressed as a 0.0000000057% chance, I simply put 50 in the calculator and did *divided by 2* over and over again until I got 0.0000000058, which is very close to the percentage that's 1 in 175 million. It took dividing 50 by two 33 times before I got near to the lottery range like that. So that's 33 bits in our photo, or 4.12 bytes, correct?

My question is, how do I figure out what the odds are (expressed as 1 in whatever or as a percentage) of the machine actually randomly creating the entire 82KB photo.. or any photo or file for that matter? I know there must be an equation that does the *divided by 2* process the 647,760 times that's needed without me actually having to punch that in the calculator that many times.

Thanks!

2. ### samiwas macrumors 68000

Joined:
Aug 26, 2006
Location:
Atlanta, GA
#2
I don't know where you got the 647,760 number from. 82KB is 82*1024*8 = 671,744 (right?)

The odds of randomly generating an 82KB image, using just binary bits, would be 2^671,744. Meaning you would actually have to multiply 2 times 2 that many times. The number is incomprehensibly huge. Even 2^100 is 1,267,650,600,228,229,000,000,000,000,000 (1.267 nonillion). That's 100 times...now imagine over 671,000 times.

Oh, and I came out with an image 3.4KB in size for 1:175,000,000. It's 2^27 and a little extra.

3. ### firestarter macrumors 603

Joined:
Dec 31, 2002
Location:
Green and pleasant land
#3
You're assuming that there's only one 'correct' picture in all those variations of numbers. The easy calculation in probability is to work out the number of variations, the more difficult bit is to work out the number of possible 'winning combinations'... it's only when you divide one into the other that you get the probability of a win.

How do you define a bit pattern that forms a recognisable face?

4. ### samiwas macrumors 68000

Joined:
Aug 26, 2006
Location:
Atlanta, GA
#4
Well, yes. If you want to take it to that level, then there is no answer. Even a single pixel being a slightest bit different in color would be considered a different result by the math but would still result in the same visual image.

5. ### miles01110 macrumors Core

Joined:
Jul 24, 2006
Location:
The Ivory Tower (I'm not coming down)
#5
Sure there is, you just have to define the parameters of the question properly. The OP hasn't.

6. ### iJohnHenry macrumors P6

Joined:
Mar 22, 2008
Location:
On tenterhooks
#6
This appears to be on the order of an infinite number of monkeys, typing on an infinite number of typewriters.

The numbers are way beyond these 'games of chance'.

7. Mar 8, 2011
Last edited: Mar 8, 2011

### Don't panic macrumors 603

Joined:
Jan 30, 2004
Location:
having a drink at Milliways
#7
the key word is 'recognizable'
there are many, many ways of render the same face recognizable, there are many 'poses' of a given face that make it recognizable as a specific person.

is the image below still recognizable as Marylin?
it's only 3.19K, and you could go way lower.
and could generate 1000s sligthly different variations of this Marylin with the same resolution, but still recognizable as her. not to mention 'other' marylin's images

so the real question is: how many bits do you need to make the simplest image of yourself? how many variations can you make of it?
answer: not that many and a lot. So if you want a high-resolution, large image of yourself, then you are definitively better of with the lottery odds (by orders of magnitude), but if you just demands ANY recognizable image of yourself, then the chance would much smaller (but i don't think small enough)

File size:
33.4 KB
Views:
70
8. ### StephenCampbell thread starter macrumors 65816

Joined:
Sep 21, 2009
#8
Well, the question, is what are the odds of a computer randomly generating a Specific image.. so, using the 82KB image as an example, every pixel would simply have to be identical to the corresponding pixel in the original image.

I don't see how we could have arrived at 4.12 bytes versus 3.4KB for 1:175,000,000. What was wrong with the way I calculated it? I took 50 and divided it by two over and over again (each of these divisions representing an additional bit being added to the image and landing on its correct position), until I came to the same number that is the percentage chance of winning a 1:175,000,000 game. It was 0.0000000058, whereas 1:175,000,000 comes out to 0.0000000057% chance.

I had to divide 50 by 2, 33 times in order to reach that 0.0000000058, meaning there are 33 bits, which is 4.12 bytes.... where am I screwing up?

9. ### samiwas macrumors 68000

Joined:
Aug 26, 2006
Location:
Atlanta, GA
#9
I don't really know how you're coming up with that number. But you are trying to get to 175,000,000 using an exponential of 2.

2 = 2 (2^1)
2 x 2 = 4 (2^2)
2 x 2 x 2 = 8 (2^3)
......
2^27 = 134,217,728
2^27.382 = ~175,000,000

So the image, as I see it, would be 27.382 bits. Since you can't have half a bit, it would be a 28 bit image.

10. Mar 10, 2011
Last edited: Mar 10, 2011

### firestarter macrumors 603

Joined:
Dec 31, 2002
Location:
Green and pleasant land
#10
Forget starting with 50 - that makes no sense. Percent means 'in a hundred'... to use percents in maths, you should convert it to a fraction by dividing by that hundred first... so 50% = 0.5

Now start again with 0.5.

11. Mar 10, 2011
Last edited: Mar 10, 2011

### Don't panic macrumors 603

Joined:
Jan 30, 2004
Location:
having a drink at Milliways
#11
other than the math aspects mentioned above, i think you might be mixing up bits and bytes.
bit (b) is the binary 0/1 option with 50% each.
byte (B) is a string of 8 bits
KB is 1024 bytes (or 8192 bits)
82KB= 671,744 bits (like SamIWas saw saying)

that is a string of 671,744 0s or 1s. the odd for ONE specific configuration of that is 1: 2^671,744 which is a mindbogglingly small number.

to make a more visual example, it's like having (roughly) a 820*819 pixel 'board' in which each pixel is either black or white (no grays or color). each decision for the color of a pixel is 50%.
on the other hand, the odds of the lottery is like using a 'board' that is 27 pixel IN TOTAL, that is 3x9, or 5x5 plus a couple dots to attach to one of the sides. you can get a basic smilie out of that, but not much more

EDIT: i see where some of the confusion originated from: in post #2 SamIWas wrote ~3.4 KB, but it should be ~3.4 Bytes. the difference with your number (4.12 Bytes) is due to the fact that you got to estimate 33 bits instead of 27/28 for the lottery odds.
Interestingly, those 5 extra bits would make actually a huge difference for the lottery, as the odds would become 1:8.5 billions

so going back to the original question, it is 'infinitely' (for practical purposes) more likely to win the lottery than for a computer to generate a specific 82KB image (if you allow for 'any' image of a specific subject it goes down orders of magnitudes)

12. Mar 10, 2011
Last edited: Mar 10, 2011

### Staff Member

Joined:
Dec 10, 2008
Location:
Finland
#12
Actually, KB is really 1000 bytes (KiloBytes) but it is often referred as 1024 bytes with computers. I think it depends on the OS you are running as Snow Leopard switched to base 10, meaning that 1KB is equal to 1000 bytes, instead of base 2 where 1KB was 1024 bytes. This means e.g. 1TB drive is seen as 1000GB instead of 976GB (if my maths are right).

If 82KB is calculated using base 2, then it is indeed 671 744 bits but if we are using an OS with base 10 (like SL), then 82KB would be 656 000 bits.

I don't know is this relevant to the actual question but I thought I would add this anyway

13. ### Don't panic macrumors 603

Joined:
Jan 30, 2004
Location:
having a drink at Milliways
#13
technically, you are right, but the new nomenclature is not really widely accepted and i think most people in the field still considers a kilobyte 2^10 bytes or 1024 (now referred to as 'kibibyte' for kilo binary bytes).

### Staff Member

Joined:
Dec 10, 2008
Location:
Finland
#14
Yup, that is right (mainly because Windows uses base 2 and it's the most popular OS). Like I added to my earlier post, I don't know is this even relevant to the actual question but the "real" size of the 82KB file depends on the OS and what base does it use.

15. ### Don't panic macrumors 603

Joined:
Jan 30, 2004
Location:
having a drink at Milliways
#15
yeah, i don't think it makes any real difference for the question in the OP.

the new system makes more sense for reasons of consistency, as kilo in every other measuring system is 1000.
also it allows companies to say they have a 64 GB drive when with the old system would be only a 60GB drive, but they contain exactly the same amount of space (in bits).

we'll see if it catches up.
considering that (in the US) we still use the demented inches/feet/yard/miles/gallons/pounds/fahrenheit nonsense, i wouldn't hold my breath.

16. ### Rodimus Prime macrumors G4

Joined:
Oct 9, 2006
#16

Umm just to point this out to you SL has ZERO effect on bits.
There are 8 bits in a byte no matter what your OS.

SL just does bytes to base 10. Not bits.

bytes has to stay base 2 numbers. It becomes really messy is you try changing it to something other than a power to 2 because then you start throwing off bits for different sizes and goes against programing substandard that are based off base 2. In standards I am talking about the size of an integer, short, long, double, float ect.

When they sell you hard drives they say they are so many bytes. Believe me it would be REALLY ugly if they tried to sell you Hard drive size based on bits.

### Staff Member

Joined:
Dec 10, 2008
Location:
Finland
#17
I didn't say it does have an effect. However, it does have an effect on how many bytes 82KB really is. With OS that uses base 10, it's 82 000 bytes. With OS that uses base 2 where 1KB=1024B, it's 83 968 bytes. That affects the amount of bits.

18. ### Rodimus Prime macrumors G4

Joined:
Oct 9, 2006
#18
yeah that is what I get for trying to do math with very little sleep. Mix that with dealing with telecommunication homework with uses bits and jumping around between them.