How to calculate probability of having at least one 2X2 same color square block on a random pixel generator?probability of at least one person having a gem of type $n$, etc.How can one calculate the probability and payout for a slot-machine that has multiple match lines?Probability of having exactly 3 fence posts painted in the same color?Probability of selecting 7 blocks such that there is at least one from each 5 colorCounting distinguishable ways of painting a cube with 4 different colors (each used at least once)Size of a $3$-colored square grid to produce a monochrome rectangleStreet combinatorics problemPermutations of these blocksGrid ProbabilityPixel coloring problem

How do I locate a classical quotation?

Placing subfig vertically

In the late 1940’s to early 1950’s what technology was available that could melt a LOT of ice?

Latest web browser compatible with Windows 98

String reversal in Python

Algorithm to convert a fixed-length string to the smallest possible collision-free representation?

Should I take out a loan for a friend to invest on my behalf?

Peter's Strange Word

The bar has been raised

Is it true that real estate prices mainly go up?

Why don't MCU characters ever seem to have language issues?

"One can do his homework in the library"

Grey hair or white hair

MTG: Can I kill an opponent in response to lethal activated abilities, and not take the damage?

Why does Captain Marvel assume the planet where she lands would recognize her credentials?

How do you like my writing?

What Happens when Passenger Refuses to Fly Boeing 737 Max?

Good for you! in Russian

Making a sword in the stone, in a medieval world without magic

Single word request: Harming the benefactor

Good allowance savings plan?

Do f-stop and exposure time perfectly cancel?

Are the terms "stab" and "staccato" synonyms?

Am I not good enough for you?



How to calculate probability of having at least one 2X2 same color square block on a random pixel generator?


probability of at least one person having a gem of type $n$, etc.How can one calculate the probability and payout for a slot-machine that has multiple match lines?Probability of having exactly 3 fence posts painted in the same color?Probability of selecting 7 blocks such that there is at least one from each 5 colorCounting distinguishable ways of painting a cube with 4 different colors (each used at least once)Size of a $3$-colored square grid to produce a monochrome rectangleStreet combinatorics problemPermutations of these blocksGrid ProbabilityPixel coloring problem













5












$begingroup$


Let's assume we have random pixel generator which has 10X10 resolution (100 pixels in total) and each pixels can have 3 different colors.
I'm trying to calculate probability of having at least one 2X2 same color square block on that screen.



Here is my logic for such calculation:



1) Odds of all pixels having same color in 2X2 square block is 1/27 (3/3^4)



2) Odds of there is at least two different colors in 2X2 square block is 26/27 (1-1/27), which is complement probability of (1)



3) There are 81 different group of 2X2 square blocks on 10X10 grid.



4) Probability of that one 2X2 square block at least having two different colors is
(26/27)^81, based on complement probability.



5) Therefore probability of at least one 2X2 square block having same color is

1-(26/27)^81=95% approximately.



However,



-4 pixels on 10X10 grid which are located at the corners (top left,top
right,bottom left & bottom right) can be only in one 2X2 square block each



-All pixels located in outermost parts except these 4, can be in two different 2X2 square blocks each



-All remaining pixels inside outermost lines can be in four different 2X2 square blocks each.



As I treated all pixels equally I didn't reflect the condition above in my calculation. How can I reflect the condition above in my calculation and have the correct probability? Is this mathematically possible to demonstrate via calculations?



Thanks a lot!










share|cite|improve this question









New contributor




franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    I cannot answer your question, but modeling this gives a probability of approximately $93.3%$
    $endgroup$
    – Daniel Mathias
    2 days ago










  • $begingroup$
    Great question! Just a note: $4/3^4 = 4/81 ne 1/27$.
    $endgroup$
    – Unit
    2 days ago










  • $begingroup$
    @unit, thanks for your attention. It should be 3/81, has been edited.
    $endgroup$
    – franckbart
    2 days ago










  • $begingroup$
    @Daniel Mathias All modelling calculations indicate approximately 93% probability. I'm trying to elaborate why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines). Can you explain?
    $endgroup$
    – franckbart
    17 hours ago










  • $begingroup$
    Your approximation is high because overlapping 2X2 blocks are not independent. A central 2X2 block shares two pixels with each of four overlapping blocks. If that block is not a solid color, then at least two of its neighbors are also not a solid color.
    $endgroup$
    – Daniel Mathias
    14 hours ago















5












$begingroup$


Let's assume we have random pixel generator which has 10X10 resolution (100 pixels in total) and each pixels can have 3 different colors.
I'm trying to calculate probability of having at least one 2X2 same color square block on that screen.



Here is my logic for such calculation:



1) Odds of all pixels having same color in 2X2 square block is 1/27 (3/3^4)



2) Odds of there is at least two different colors in 2X2 square block is 26/27 (1-1/27), which is complement probability of (1)



3) There are 81 different group of 2X2 square blocks on 10X10 grid.



4) Probability of that one 2X2 square block at least having two different colors is
(26/27)^81, based on complement probability.



5) Therefore probability of at least one 2X2 square block having same color is

1-(26/27)^81=95% approximately.



However,



-4 pixels on 10X10 grid which are located at the corners (top left,top
right,bottom left & bottom right) can be only in one 2X2 square block each



-All pixels located in outermost parts except these 4, can be in two different 2X2 square blocks each



-All remaining pixels inside outermost lines can be in four different 2X2 square blocks each.



As I treated all pixels equally I didn't reflect the condition above in my calculation. How can I reflect the condition above in my calculation and have the correct probability? Is this mathematically possible to demonstrate via calculations?



Thanks a lot!










share|cite|improve this question









New contributor




franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    I cannot answer your question, but modeling this gives a probability of approximately $93.3%$
    $endgroup$
    – Daniel Mathias
    2 days ago










  • $begingroup$
    Great question! Just a note: $4/3^4 = 4/81 ne 1/27$.
    $endgroup$
    – Unit
    2 days ago










  • $begingroup$
    @unit, thanks for your attention. It should be 3/81, has been edited.
    $endgroup$
    – franckbart
    2 days ago










  • $begingroup$
    @Daniel Mathias All modelling calculations indicate approximately 93% probability. I'm trying to elaborate why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines). Can you explain?
    $endgroup$
    – franckbart
    17 hours ago










  • $begingroup$
    Your approximation is high because overlapping 2X2 blocks are not independent. A central 2X2 block shares two pixels with each of four overlapping blocks. If that block is not a solid color, then at least two of its neighbors are also not a solid color.
    $endgroup$
    – Daniel Mathias
    14 hours ago













5












5








5


2



$begingroup$


Let's assume we have random pixel generator which has 10X10 resolution (100 pixels in total) and each pixels can have 3 different colors.
I'm trying to calculate probability of having at least one 2X2 same color square block on that screen.



Here is my logic for such calculation:



1) Odds of all pixels having same color in 2X2 square block is 1/27 (3/3^4)



2) Odds of there is at least two different colors in 2X2 square block is 26/27 (1-1/27), which is complement probability of (1)



3) There are 81 different group of 2X2 square blocks on 10X10 grid.



4) Probability of that one 2X2 square block at least having two different colors is
(26/27)^81, based on complement probability.



5) Therefore probability of at least one 2X2 square block having same color is

1-(26/27)^81=95% approximately.



However,



-4 pixels on 10X10 grid which are located at the corners (top left,top
right,bottom left & bottom right) can be only in one 2X2 square block each



-All pixels located in outermost parts except these 4, can be in two different 2X2 square blocks each



-All remaining pixels inside outermost lines can be in four different 2X2 square blocks each.



As I treated all pixels equally I didn't reflect the condition above in my calculation. How can I reflect the condition above in my calculation and have the correct probability? Is this mathematically possible to demonstrate via calculations?



Thanks a lot!










share|cite|improve this question









New contributor




franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




Let's assume we have random pixel generator which has 10X10 resolution (100 pixels in total) and each pixels can have 3 different colors.
I'm trying to calculate probability of having at least one 2X2 same color square block on that screen.



Here is my logic for such calculation:



1) Odds of all pixels having same color in 2X2 square block is 1/27 (3/3^4)



2) Odds of there is at least two different colors in 2X2 square block is 26/27 (1-1/27), which is complement probability of (1)



3) There are 81 different group of 2X2 square blocks on 10X10 grid.



4) Probability of that one 2X2 square block at least having two different colors is
(26/27)^81, based on complement probability.



5) Therefore probability of at least one 2X2 square block having same color is

1-(26/27)^81=95% approximately.



However,



-4 pixels on 10X10 grid which are located at the corners (top left,top
right,bottom left & bottom right) can be only in one 2X2 square block each



-All pixels located in outermost parts except these 4, can be in two different 2X2 square blocks each



-All remaining pixels inside outermost lines can be in four different 2X2 square blocks each.



As I treated all pixels equally I didn't reflect the condition above in my calculation. How can I reflect the condition above in my calculation and have the correct probability? Is this mathematically possible to demonstrate via calculations?



Thanks a lot!







probability sequences-and-series combinatorics statistics random-variables






share|cite|improve this question









New contributor




franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|cite|improve this question









New contributor




franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|cite|improve this question




share|cite|improve this question








edited 2 days ago







franckbart













New contributor




franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









franckbartfranckbart

263




263




New contributor




franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






franckbart is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    I cannot answer your question, but modeling this gives a probability of approximately $93.3%$
    $endgroup$
    – Daniel Mathias
    2 days ago










  • $begingroup$
    Great question! Just a note: $4/3^4 = 4/81 ne 1/27$.
    $endgroup$
    – Unit
    2 days ago










  • $begingroup$
    @unit, thanks for your attention. It should be 3/81, has been edited.
    $endgroup$
    – franckbart
    2 days ago










  • $begingroup$
    @Daniel Mathias All modelling calculations indicate approximately 93% probability. I'm trying to elaborate why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines). Can you explain?
    $endgroup$
    – franckbart
    17 hours ago










  • $begingroup$
    Your approximation is high because overlapping 2X2 blocks are not independent. A central 2X2 block shares two pixels with each of four overlapping blocks. If that block is not a solid color, then at least two of its neighbors are also not a solid color.
    $endgroup$
    – Daniel Mathias
    14 hours ago
















  • $begingroup$
    I cannot answer your question, but modeling this gives a probability of approximately $93.3%$
    $endgroup$
    – Daniel Mathias
    2 days ago










  • $begingroup$
    Great question! Just a note: $4/3^4 = 4/81 ne 1/27$.
    $endgroup$
    – Unit
    2 days ago










  • $begingroup$
    @unit, thanks for your attention. It should be 3/81, has been edited.
    $endgroup$
    – franckbart
    2 days ago










  • $begingroup$
    @Daniel Mathias All modelling calculations indicate approximately 93% probability. I'm trying to elaborate why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines). Can you explain?
    $endgroup$
    – franckbart
    17 hours ago










  • $begingroup$
    Your approximation is high because overlapping 2X2 blocks are not independent. A central 2X2 block shares two pixels with each of four overlapping blocks. If that block is not a solid color, then at least two of its neighbors are also not a solid color.
    $endgroup$
    – Daniel Mathias
    14 hours ago















$begingroup$
I cannot answer your question, but modeling this gives a probability of approximately $93.3%$
$endgroup$
– Daniel Mathias
2 days ago




$begingroup$
I cannot answer your question, but modeling this gives a probability of approximately $93.3%$
$endgroup$
– Daniel Mathias
2 days ago












$begingroup$
Great question! Just a note: $4/3^4 = 4/81 ne 1/27$.
$endgroup$
– Unit
2 days ago




$begingroup$
Great question! Just a note: $4/3^4 = 4/81 ne 1/27$.
$endgroup$
– Unit
2 days ago












$begingroup$
@unit, thanks for your attention. It should be 3/81, has been edited.
$endgroup$
– franckbart
2 days ago




$begingroup$
@unit, thanks for your attention. It should be 3/81, has been edited.
$endgroup$
– franckbart
2 days ago












$begingroup$
@Daniel Mathias All modelling calculations indicate approximately 93% probability. I'm trying to elaborate why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines). Can you explain?
$endgroup$
– franckbart
17 hours ago




$begingroup$
@Daniel Mathias All modelling calculations indicate approximately 93% probability. I'm trying to elaborate why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines). Can you explain?
$endgroup$
– franckbart
17 hours ago












$begingroup$
Your approximation is high because overlapping 2X2 blocks are not independent. A central 2X2 block shares two pixels with each of four overlapping blocks. If that block is not a solid color, then at least two of its neighbors are also not a solid color.
$endgroup$
– Daniel Mathias
14 hours ago




$begingroup$
Your approximation is high because overlapping 2X2 blocks are not independent. A central 2X2 block shares two pixels with each of four overlapping blocks. If that block is not a solid color, then at least two of its neighbors are also not a solid color.
$endgroup$
– Daniel Mathias
14 hours ago










1 Answer
1






active

oldest

votes


















1












$begingroup$

I tend to believe that there is no simple formula for that, but you can use ideas from so-called "dynamic programming with profile" to calculate it.



Let $x$ be the number of 'bad' colorings (with no single-colored $2*2$ squares). Clearly the answer is $$1-fracx3^100$$

Next, let $f(n, mask)$ (where $n in 0 .. 9$ and $mask in 1, 2, 3 ^ 10$, $1, 2, 3$ refers to colors) be the number of ways to paint first $n+1$ rows so that:

1) There is no single-colored $2*2$ square

2) The last row coloring is determined by $mask$



Clearly $$x = sum_mask in 1, 2, 3 ^ 10f(9, mask)$$



We use recurrent formula in order to calculate $f(9, mask)$


Thus, $$f(n, mask) = sum_mask' in 1, 2, 3 ^ 10f(n - 1, mask') * permitted(mask', mask)$$ where $$permitted(mask1, mask2) = begincases
1, & textif $mask2$ painted next to $mask1$ doesn't produce single-colored 2*2 square \
0, & textotherwise endcases$$



and
$$f(0, mask) = 1$$
for any $mask$



The formula above simply reflects the fact that any coloring of the first $n$ rows is proper combination of coloring of first $n - 1$ rows and the last one, and all you need to ensure that the coloring of the last row (defined by $mask$) together with the coloring of previous row (defined by $mask'$) don't form a single-colored square.



If you just need a formula then the job is done. If you actually need to get a number you will have to wait a couple of hours (or even days) waiting your computer to do $10 * 3 ^ 2 *10 approx 3 * 10^10$ operations calculating all these values. It will take a time, but it is not impossible as full brute-force taking $3^100 approx 5 * 10 ^ 47$ which is almost forever.



Upd:


By these formulas the exact number of colorings with no single-colored $2*2$ square is $$34588239301492881803538634375825365877151370240$$ Thus, the probability is $$frac3^100 - 345882393014928818035386343758253658771513702403^100 = 0.9328875670549894$$






share|cite|improve this answer










New contributor




Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$












  • $begingroup$
    Thanks for your insights. I am not that knowledgeable about programming. Is the formula with masks you've provided a mathematical formula or programming formula? I am curious if there is any way to make a step by step reasoning for getting a percentage with simple probability calculations as I demonstrated in the details of my question.
    $endgroup$
    – franckbart
    2 days ago











  • $begingroup$
    It is a mathematical formula, however, the only way to actually evaluate it to use a computer as a huge amount of values are to be calculated. As I said before, I bet there is no way to precisely calculate it using only simple probability reasoning. Btw, I've just run the program to calculate it, hope tomorrow it will give away the answer :)
    $endgroup$
    – Vladislav
    2 days ago











  • $begingroup$
    thanks! I assume it should give us the probability as 93,3%. This probability has been so far confirmed by two people (one answer is in the comments) who used computer modelling.
    $endgroup$
    – franckbart
    2 days ago






  • 1




    $begingroup$
    I updated the answer. The modelling didn't lie :)
    $endgroup$
    – Vladislav
    yesterday










  • $begingroup$
    Your approach with mathematical formula is appreciated :) I'm indeed pondering why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines) What do you think?
    $endgroup$
    – franckbart
    yesterday











Your Answer





StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






franckbart is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3142232%2fhow-to-calculate-probability-of-having-at-least-one-2x2-same-color-square-block%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1












$begingroup$

I tend to believe that there is no simple formula for that, but you can use ideas from so-called "dynamic programming with profile" to calculate it.



Let $x$ be the number of 'bad' colorings (with no single-colored $2*2$ squares). Clearly the answer is $$1-fracx3^100$$

Next, let $f(n, mask)$ (where $n in 0 .. 9$ and $mask in 1, 2, 3 ^ 10$, $1, 2, 3$ refers to colors) be the number of ways to paint first $n+1$ rows so that:

1) There is no single-colored $2*2$ square

2) The last row coloring is determined by $mask$



Clearly $$x = sum_mask in 1, 2, 3 ^ 10f(9, mask)$$



We use recurrent formula in order to calculate $f(9, mask)$


Thus, $$f(n, mask) = sum_mask' in 1, 2, 3 ^ 10f(n - 1, mask') * permitted(mask', mask)$$ where $$permitted(mask1, mask2) = begincases
1, & textif $mask2$ painted next to $mask1$ doesn't produce single-colored 2*2 square \
0, & textotherwise endcases$$



and
$$f(0, mask) = 1$$
for any $mask$



The formula above simply reflects the fact that any coloring of the first $n$ rows is proper combination of coloring of first $n - 1$ rows and the last one, and all you need to ensure that the coloring of the last row (defined by $mask$) together with the coloring of previous row (defined by $mask'$) don't form a single-colored square.



If you just need a formula then the job is done. If you actually need to get a number you will have to wait a couple of hours (or even days) waiting your computer to do $10 * 3 ^ 2 *10 approx 3 * 10^10$ operations calculating all these values. It will take a time, but it is not impossible as full brute-force taking $3^100 approx 5 * 10 ^ 47$ which is almost forever.



Upd:


By these formulas the exact number of colorings with no single-colored $2*2$ square is $$34588239301492881803538634375825365877151370240$$ Thus, the probability is $$frac3^100 - 345882393014928818035386343758253658771513702403^100 = 0.9328875670549894$$






share|cite|improve this answer










New contributor




Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$












  • $begingroup$
    Thanks for your insights. I am not that knowledgeable about programming. Is the formula with masks you've provided a mathematical formula or programming formula? I am curious if there is any way to make a step by step reasoning for getting a percentage with simple probability calculations as I demonstrated in the details of my question.
    $endgroup$
    – franckbart
    2 days ago











  • $begingroup$
    It is a mathematical formula, however, the only way to actually evaluate it to use a computer as a huge amount of values are to be calculated. As I said before, I bet there is no way to precisely calculate it using only simple probability reasoning. Btw, I've just run the program to calculate it, hope tomorrow it will give away the answer :)
    $endgroup$
    – Vladislav
    2 days ago











  • $begingroup$
    thanks! I assume it should give us the probability as 93,3%. This probability has been so far confirmed by two people (one answer is in the comments) who used computer modelling.
    $endgroup$
    – franckbart
    2 days ago






  • 1




    $begingroup$
    I updated the answer. The modelling didn't lie :)
    $endgroup$
    – Vladislav
    yesterday










  • $begingroup$
    Your approach with mathematical formula is appreciated :) I'm indeed pondering why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines) What do you think?
    $endgroup$
    – franckbart
    yesterday
















1












$begingroup$

I tend to believe that there is no simple formula for that, but you can use ideas from so-called "dynamic programming with profile" to calculate it.



Let $x$ be the number of 'bad' colorings (with no single-colored $2*2$ squares). Clearly the answer is $$1-fracx3^100$$

Next, let $f(n, mask)$ (where $n in 0 .. 9$ and $mask in 1, 2, 3 ^ 10$, $1, 2, 3$ refers to colors) be the number of ways to paint first $n+1$ rows so that:

1) There is no single-colored $2*2$ square

2) The last row coloring is determined by $mask$



Clearly $$x = sum_mask in 1, 2, 3 ^ 10f(9, mask)$$



We use recurrent formula in order to calculate $f(9, mask)$


Thus, $$f(n, mask) = sum_mask' in 1, 2, 3 ^ 10f(n - 1, mask') * permitted(mask', mask)$$ where $$permitted(mask1, mask2) = begincases
1, & textif $mask2$ painted next to $mask1$ doesn't produce single-colored 2*2 square \
0, & textotherwise endcases$$



and
$$f(0, mask) = 1$$
for any $mask$



The formula above simply reflects the fact that any coloring of the first $n$ rows is proper combination of coloring of first $n - 1$ rows and the last one, and all you need to ensure that the coloring of the last row (defined by $mask$) together with the coloring of previous row (defined by $mask'$) don't form a single-colored square.



If you just need a formula then the job is done. If you actually need to get a number you will have to wait a couple of hours (or even days) waiting your computer to do $10 * 3 ^ 2 *10 approx 3 * 10^10$ operations calculating all these values. It will take a time, but it is not impossible as full brute-force taking $3^100 approx 5 * 10 ^ 47$ which is almost forever.



Upd:


By these formulas the exact number of colorings with no single-colored $2*2$ square is $$34588239301492881803538634375825365877151370240$$ Thus, the probability is $$frac3^100 - 345882393014928818035386343758253658771513702403^100 = 0.9328875670549894$$






share|cite|improve this answer










New contributor




Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$












  • $begingroup$
    Thanks for your insights. I am not that knowledgeable about programming. Is the formula with masks you've provided a mathematical formula or programming formula? I am curious if there is any way to make a step by step reasoning for getting a percentage with simple probability calculations as I demonstrated in the details of my question.
    $endgroup$
    – franckbart
    2 days ago











  • $begingroup$
    It is a mathematical formula, however, the only way to actually evaluate it to use a computer as a huge amount of values are to be calculated. As I said before, I bet there is no way to precisely calculate it using only simple probability reasoning. Btw, I've just run the program to calculate it, hope tomorrow it will give away the answer :)
    $endgroup$
    – Vladislav
    2 days ago











  • $begingroup$
    thanks! I assume it should give us the probability as 93,3%. This probability has been so far confirmed by two people (one answer is in the comments) who used computer modelling.
    $endgroup$
    – franckbart
    2 days ago






  • 1




    $begingroup$
    I updated the answer. The modelling didn't lie :)
    $endgroup$
    – Vladislav
    yesterday










  • $begingroup$
    Your approach with mathematical formula is appreciated :) I'm indeed pondering why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines) What do you think?
    $endgroup$
    – franckbart
    yesterday














1












1








1





$begingroup$

I tend to believe that there is no simple formula for that, but you can use ideas from so-called "dynamic programming with profile" to calculate it.



Let $x$ be the number of 'bad' colorings (with no single-colored $2*2$ squares). Clearly the answer is $$1-fracx3^100$$

Next, let $f(n, mask)$ (where $n in 0 .. 9$ and $mask in 1, 2, 3 ^ 10$, $1, 2, 3$ refers to colors) be the number of ways to paint first $n+1$ rows so that:

1) There is no single-colored $2*2$ square

2) The last row coloring is determined by $mask$



Clearly $$x = sum_mask in 1, 2, 3 ^ 10f(9, mask)$$



We use recurrent formula in order to calculate $f(9, mask)$


Thus, $$f(n, mask) = sum_mask' in 1, 2, 3 ^ 10f(n - 1, mask') * permitted(mask', mask)$$ where $$permitted(mask1, mask2) = begincases
1, & textif $mask2$ painted next to $mask1$ doesn't produce single-colored 2*2 square \
0, & textotherwise endcases$$



and
$$f(0, mask) = 1$$
for any $mask$



The formula above simply reflects the fact that any coloring of the first $n$ rows is proper combination of coloring of first $n - 1$ rows and the last one, and all you need to ensure that the coloring of the last row (defined by $mask$) together with the coloring of previous row (defined by $mask'$) don't form a single-colored square.



If you just need a formula then the job is done. If you actually need to get a number you will have to wait a couple of hours (or even days) waiting your computer to do $10 * 3 ^ 2 *10 approx 3 * 10^10$ operations calculating all these values. It will take a time, but it is not impossible as full brute-force taking $3^100 approx 5 * 10 ^ 47$ which is almost forever.



Upd:


By these formulas the exact number of colorings with no single-colored $2*2$ square is $$34588239301492881803538634375825365877151370240$$ Thus, the probability is $$frac3^100 - 345882393014928818035386343758253658771513702403^100 = 0.9328875670549894$$






share|cite|improve this answer










New contributor




Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$



I tend to believe that there is no simple formula for that, but you can use ideas from so-called "dynamic programming with profile" to calculate it.



Let $x$ be the number of 'bad' colorings (with no single-colored $2*2$ squares). Clearly the answer is $$1-fracx3^100$$

Next, let $f(n, mask)$ (where $n in 0 .. 9$ and $mask in 1, 2, 3 ^ 10$, $1, 2, 3$ refers to colors) be the number of ways to paint first $n+1$ rows so that:

1) There is no single-colored $2*2$ square

2) The last row coloring is determined by $mask$



Clearly $$x = sum_mask in 1, 2, 3 ^ 10f(9, mask)$$



We use recurrent formula in order to calculate $f(9, mask)$


Thus, $$f(n, mask) = sum_mask' in 1, 2, 3 ^ 10f(n - 1, mask') * permitted(mask', mask)$$ where $$permitted(mask1, mask2) = begincases
1, & textif $mask2$ painted next to $mask1$ doesn't produce single-colored 2*2 square \
0, & textotherwise endcases$$



and
$$f(0, mask) = 1$$
for any $mask$



The formula above simply reflects the fact that any coloring of the first $n$ rows is proper combination of coloring of first $n - 1$ rows and the last one, and all you need to ensure that the coloring of the last row (defined by $mask$) together with the coloring of previous row (defined by $mask'$) don't form a single-colored square.



If you just need a formula then the job is done. If you actually need to get a number you will have to wait a couple of hours (or even days) waiting your computer to do $10 * 3 ^ 2 *10 approx 3 * 10^10$ operations calculating all these values. It will take a time, but it is not impossible as full brute-force taking $3^100 approx 5 * 10 ^ 47$ which is almost forever.



Upd:


By these formulas the exact number of colorings with no single-colored $2*2$ square is $$34588239301492881803538634375825365877151370240$$ Thus, the probability is $$frac3^100 - 345882393014928818035386343758253658771513702403^100 = 0.9328875670549894$$







share|cite|improve this answer










New contributor




Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|cite|improve this answer



share|cite|improve this answer








edited yesterday





















New contributor




Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 2 days ago









VladislavVladislav

564




564




New contributor




Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Vladislav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    Thanks for your insights. I am not that knowledgeable about programming. Is the formula with masks you've provided a mathematical formula or programming formula? I am curious if there is any way to make a step by step reasoning for getting a percentage with simple probability calculations as I demonstrated in the details of my question.
    $endgroup$
    – franckbart
    2 days ago











  • $begingroup$
    It is a mathematical formula, however, the only way to actually evaluate it to use a computer as a huge amount of values are to be calculated. As I said before, I bet there is no way to precisely calculate it using only simple probability reasoning. Btw, I've just run the program to calculate it, hope tomorrow it will give away the answer :)
    $endgroup$
    – Vladislav
    2 days ago











  • $begingroup$
    thanks! I assume it should give us the probability as 93,3%. This probability has been so far confirmed by two people (one answer is in the comments) who used computer modelling.
    $endgroup$
    – franckbart
    2 days ago






  • 1




    $begingroup$
    I updated the answer. The modelling didn't lie :)
    $endgroup$
    – Vladislav
    yesterday










  • $begingroup$
    Your approach with mathematical formula is appreciated :) I'm indeed pondering why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines) What do you think?
    $endgroup$
    – franckbart
    yesterday

















  • $begingroup$
    Thanks for your insights. I am not that knowledgeable about programming. Is the formula with masks you've provided a mathematical formula or programming formula? I am curious if there is any way to make a step by step reasoning for getting a percentage with simple probability calculations as I demonstrated in the details of my question.
    $endgroup$
    – franckbart
    2 days ago











  • $begingroup$
    It is a mathematical formula, however, the only way to actually evaluate it to use a computer as a huge amount of values are to be calculated. As I said before, I bet there is no way to precisely calculate it using only simple probability reasoning. Btw, I've just run the program to calculate it, hope tomorrow it will give away the answer :)
    $endgroup$
    – Vladislav
    2 days ago











  • $begingroup$
    thanks! I assume it should give us the probability as 93,3%. This probability has been so far confirmed by two people (one answer is in the comments) who used computer modelling.
    $endgroup$
    – franckbart
    2 days ago






  • 1




    $begingroup$
    I updated the answer. The modelling didn't lie :)
    $endgroup$
    – Vladislav
    yesterday










  • $begingroup$
    Your approach with mathematical formula is appreciated :) I'm indeed pondering why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines) What do you think?
    $endgroup$
    – franckbart
    yesterday
















$begingroup$
Thanks for your insights. I am not that knowledgeable about programming. Is the formula with masks you've provided a mathematical formula or programming formula? I am curious if there is any way to make a step by step reasoning for getting a percentage with simple probability calculations as I demonstrated in the details of my question.
$endgroup$
– franckbart
2 days ago





$begingroup$
Thanks for your insights. I am not that knowledgeable about programming. Is the formula with masks you've provided a mathematical formula or programming formula? I am curious if there is any way to make a step by step reasoning for getting a percentage with simple probability calculations as I demonstrated in the details of my question.
$endgroup$
– franckbart
2 days ago













$begingroup$
It is a mathematical formula, however, the only way to actually evaluate it to use a computer as a huge amount of values are to be calculated. As I said before, I bet there is no way to precisely calculate it using only simple probability reasoning. Btw, I've just run the program to calculate it, hope tomorrow it will give away the answer :)
$endgroup$
– Vladislav
2 days ago





$begingroup$
It is a mathematical formula, however, the only way to actually evaluate it to use a computer as a huge amount of values are to be calculated. As I said before, I bet there is no way to precisely calculate it using only simple probability reasoning. Btw, I've just run the program to calculate it, hope tomorrow it will give away the answer :)
$endgroup$
– Vladislav
2 days ago













$begingroup$
thanks! I assume it should give us the probability as 93,3%. This probability has been so far confirmed by two people (one answer is in the comments) who used computer modelling.
$endgroup$
– franckbart
2 days ago




$begingroup$
thanks! I assume it should give us the probability as 93,3%. This probability has been so far confirmed by two people (one answer is in the comments) who used computer modelling.
$endgroup$
– franckbart
2 days ago




1




1




$begingroup$
I updated the answer. The modelling didn't lie :)
$endgroup$
– Vladislav
yesterday




$begingroup$
I updated the answer. The modelling didn't lie :)
$endgroup$
– Vladislav
yesterday












$begingroup$
Your approach with mathematical formula is appreciated :) I'm indeed pondering why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines) What do you think?
$endgroup$
– franckbart
yesterday





$begingroup$
Your approach with mathematical formula is appreciated :) I'm indeed pondering why my basic approach above ends up with 95% probability which is a little high than correct result. I think multiplying probability of each 2X2 square blocks 81 times just gives probability of a sequence. It doesn't take into account position of 2X2 square blocks in the grid. Probability of each pixel changes based on where they are positioned (corners, outermost lines and inside of outermost lines) What do you think?
$endgroup$
– franckbart
yesterday











franckbart is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















franckbart is a new contributor. Be nice, and check out our Code of Conduct.












franckbart is a new contributor. Be nice, and check out our Code of Conduct.











franckbart is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3142232%2fhow-to-calculate-probability-of-having-at-least-one-2x2-same-color-square-block%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Lowndes Grove History Architecture References Navigation menu32°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661132°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661178002500"National Register Information System"Historic houses of South Carolina"Lowndes Grove""+32° 48' 6.00", −79° 57' 58.00""Lowndes Grove, Charleston County (260 St. Margaret St., Charleston)""Lowndes Grove"The Charleston ExpositionIt Happened in South Carolina"Lowndes Grove (House), Saint Margaret Street & Sixth Avenue, Charleston, Charleston County, SC(Photographs)"Plantations of the Carolina Low Countrye

random experiment with two different functions on unit interval Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Random variable and probability space notionsRandom Walk with EdgesFinding functions where the increase over a random interval is Poisson distributedNumber of days until dayCan an observed event in fact be of zero probability?Unit random processmodels of coins and uniform distributionHow to get the number of successes given $n$ trials , probability $P$ and a random variable $X$Absorbing Markov chain in a computer. Is “almost every” turned into always convergence in computer executions?Stopped random walk is not uniformly integrable

How should I support this large drywall patch? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How do I cover large gaps in drywall?How do I keep drywall around a patch from crumbling?Can I glue a second layer of drywall?How to patch long strip on drywall?Large drywall patch: how to avoid bulging seams?Drywall Mesh Patch vs. Bulge? To remove or not to remove?How to fix this drywall job?Prep drywall before backsplashWhat's the best way to fix this horrible drywall patch job?Drywall patching using 3M Patch Plus Primer