Chose the correct inputs for a Monte Carlo simulation The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Why does Monte-Carlo integration work better than naive numerical integration in high dimensions?Monte Carlo SimulationDensity estimation using conditional Monte Carlo simulationConvergence of Monte Carlo simulationcomputing the area of a region using Monte Carlo integrationMonte Carlo Simulation/StatsMonte Carlo Confidence Interval for Standard DeviationDetermine number of trials in Monte Carlo simulationCombinatorics - h men, m women and n chairs in a circular tableCan we use the control variate Monte Carlo variance reduction approach to estimate variance?

First use of “packing” as in carrying a gun

Does Parliament need to approve the new Brexit delay to 31 October 2019?

How to test the equality of two Pearson correlation coefficients computed from the same sample?

How long does the line of fire that you can create as an action using the Investiture of Flame spell last?

Do working physicists consider Newtonian mechanics to be "falsified"?

Can a 1st-level character have an ability score above 18?

Windows 10: How to Lock (not sleep) laptop on lid close?

How to delete random line from file using Unix command?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

What's the point in a preamp?

How many people can fit inside Mordenkainen's Magnificent Mansion?

In horse breeding, what is the female equivalent of putting a horse out "to stud"?

What is this lever in Argentinian toilets?

When did F become S in typeography, and why?

Why is superheterodyning better than direct conversion?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Can smartphones with the same camera sensor have different image quality?

Working through the single responsibility principle (SRP) in Python when calls are expensive

Why can't devices on different VLANs, but on the same subnet, communicate?

Derivation tree not rendering

How did passengers keep warm on sail ships?

Hiding Certain Lines on Table

How does ice melt when immersed in water?

Would an alien lifeform be able to achieve space travel if lacking in vision?



Chose the correct inputs for a Monte Carlo simulation



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Why does Monte-Carlo integration work better than naive numerical integration in high dimensions?Monte Carlo SimulationDensity estimation using conditional Monte Carlo simulationConvergence of Monte Carlo simulationcomputing the area of a region using Monte Carlo integrationMonte Carlo Simulation/StatsMonte Carlo Confidence Interval for Standard DeviationDetermine number of trials in Monte Carlo simulationCombinatorics - h men, m women and n chairs in a circular tableCan we use the control variate Monte Carlo variance reduction approach to estimate variance?










0












$begingroup$


Motivation



If have found my self answering to a SO question about Monte Carlo simulation. The model to design is stated as this:




Let 20 people, including exactly 3 women, seat themselves randomly at
4 tables (denoted A, B, C and D) of 5 persons each, with all arrangements
equally likely.



Let $X$ be the number of tables at which no women sit.
Write a Monte Carlo simulation to estimate the expectation of $E[X]$
and also estimate the probability $P(A=0)$ that no women sit at table A. Run
the simulation for 3 cases (100,1000,10000)




First, I drafted a first naïve solution, and then when refactorizing I changed the way possible inputs were drawn. I observed that solutions did not converged to the same quantities. Elements supporting this observation are available in my answer.



Implementations



First implementation



  • Create a vector of length $20$ populated as follow $(1,1,1,0,dots,0)$ where $1$ stands for a woman and $0$ for a man;

  • Draw a random permutation of this vector;

  • Assess the number of tables with no woman (splitting the vector into 4 tables);

Second implementation



  • Construct a set $S$ composed by $3$ numbers sampled from $1,dots,4$, it represents table where at least one woman sit with $0<#S<4$;

  • Here $X$ is simply assessed by $4 - #S$;

Quantities



Then, for each process, output are processed as follow:



  • Initialize empty Counters;

  • For each sample in $1,dots N$:

    • Draw an experiment and assess the value of $X$, this is where de difference lies;

    • Add $1$ to the modality $X=k$ in a dictionary of integer;

    • Add $1$ if table A is empty in an integer;


  • Rationalize counts with $N$ to get frequencies;

  • Assess the expected value $E[X]$;

Models



First implementation



I think the first implementation can be modeled as follow:



$$
#Omega = C^5_20C^5_15C^5_10C^5_5 = 11732745024
$$



With probabilities:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= frac4!3!fracC^1_3C^4_17C^1_3C^4_13C^1_3C^4_9C^5_5#Omega = frac2557 simeq 0.4386 \
P(X=2) &= frac4!2!fracC^1_3C^4_17C^2_2C^3_13C^5_10C^5_5#Omega = frac1019 simeq 0.5263 \
P(X=3) &= frac4!3!fracC^3_3C^2_17C^5_15C^5_10C^5_5#Omega = frac257 simeq 0.03509 \
P(X=4) &= 0
endalign
$$



Then the expected value is:



$$
mathrmE[X] = frac2557 + 2frac1019 + 3frac257 = frac9157 = 1.5965
$$



And the probability of having not a woman a table A is:



$$
P(A=0) = fracC^5_17#Omegaleft(
3 C^3_3C^2_12C^5_10C^5_5 +
6 C^1_3C^4_12C^2_2C^3_8C^5_5 +
C^1_3C^4_12C^1_2C^4_8C^1_1C^4_4
right) = frac91228 simeq 0.3991
$$



Which is compliant with results of method runMonteCarlo.



Second Implementation



And the second implementation can be modeled by a locker with 4 symbols (A, B, C, D) and 3 digits, then there is $# Omega = 4^3 = 64$ possible setups.



Then we can assess $P(X=k)$ using combinatorics:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= fracC^1_4 C^1_3 C^1_24^3 = frac2464 = 0.375 \
P(X=2) &= fracC^1_4 C^1_3 C^2_34^3 = frac3664 = 0.5625\
P(X=3) &= fracC^1_44^3 = frac464 = 0.0625 \
P(X=4) &= 0
endalign
$$



The expectation of $X$ is:



$$
mathrmE[X] = frac2464 + 2frac3664 + 3frac464 = frac2716 = 1.6875
$$



And the probability of having no woman at the table A is then:



$$
P(A=0) = frac3^34^3 = frac2764 = 0.421875
$$



Which complies with the result of method runMonteCarlo2.



Questions



  • Are my models correct?

  • For the given problem, what is the correct solution?









share|cite|improve this question











$endgroup$











  • $begingroup$
    It all depends on what you mean by "Then compute relevant quantities."
    $endgroup$
    – TonyK
    Mar 22 at 11:15











  • $begingroup$
    @TonyK Thank you for commenting, I have updated my question to address how do I compute those quantities.
    $endgroup$
    – jlandercy
    Mar 22 at 11:34










  • $begingroup$
    In your second solution, when you say you sample 3 numbers from 1,2,3,4, is that sampling with or without replacement? (In either case, your second solution seems suspect.)
    $endgroup$
    – awkward
    Mar 22 at 12:51















0












$begingroup$


Motivation



If have found my self answering to a SO question about Monte Carlo simulation. The model to design is stated as this:




Let 20 people, including exactly 3 women, seat themselves randomly at
4 tables (denoted A, B, C and D) of 5 persons each, with all arrangements
equally likely.



Let $X$ be the number of tables at which no women sit.
Write a Monte Carlo simulation to estimate the expectation of $E[X]$
and also estimate the probability $P(A=0)$ that no women sit at table A. Run
the simulation for 3 cases (100,1000,10000)




First, I drafted a first naïve solution, and then when refactorizing I changed the way possible inputs were drawn. I observed that solutions did not converged to the same quantities. Elements supporting this observation are available in my answer.



Implementations



First implementation



  • Create a vector of length $20$ populated as follow $(1,1,1,0,dots,0)$ where $1$ stands for a woman and $0$ for a man;

  • Draw a random permutation of this vector;

  • Assess the number of tables with no woman (splitting the vector into 4 tables);

Second implementation



  • Construct a set $S$ composed by $3$ numbers sampled from $1,dots,4$, it represents table where at least one woman sit with $0<#S<4$;

  • Here $X$ is simply assessed by $4 - #S$;

Quantities



Then, for each process, output are processed as follow:



  • Initialize empty Counters;

  • For each sample in $1,dots N$:

    • Draw an experiment and assess the value of $X$, this is where de difference lies;

    • Add $1$ to the modality $X=k$ in a dictionary of integer;

    • Add $1$ if table A is empty in an integer;


  • Rationalize counts with $N$ to get frequencies;

  • Assess the expected value $E[X]$;

Models



First implementation



I think the first implementation can be modeled as follow:



$$
#Omega = C^5_20C^5_15C^5_10C^5_5 = 11732745024
$$



With probabilities:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= frac4!3!fracC^1_3C^4_17C^1_3C^4_13C^1_3C^4_9C^5_5#Omega = frac2557 simeq 0.4386 \
P(X=2) &= frac4!2!fracC^1_3C^4_17C^2_2C^3_13C^5_10C^5_5#Omega = frac1019 simeq 0.5263 \
P(X=3) &= frac4!3!fracC^3_3C^2_17C^5_15C^5_10C^5_5#Omega = frac257 simeq 0.03509 \
P(X=4) &= 0
endalign
$$



Then the expected value is:



$$
mathrmE[X] = frac2557 + 2frac1019 + 3frac257 = frac9157 = 1.5965
$$



And the probability of having not a woman a table A is:



$$
P(A=0) = fracC^5_17#Omegaleft(
3 C^3_3C^2_12C^5_10C^5_5 +
6 C^1_3C^4_12C^2_2C^3_8C^5_5 +
C^1_3C^4_12C^1_2C^4_8C^1_1C^4_4
right) = frac91228 simeq 0.3991
$$



Which is compliant with results of method runMonteCarlo.



Second Implementation



And the second implementation can be modeled by a locker with 4 symbols (A, B, C, D) and 3 digits, then there is $# Omega = 4^3 = 64$ possible setups.



Then we can assess $P(X=k)$ using combinatorics:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= fracC^1_4 C^1_3 C^1_24^3 = frac2464 = 0.375 \
P(X=2) &= fracC^1_4 C^1_3 C^2_34^3 = frac3664 = 0.5625\
P(X=3) &= fracC^1_44^3 = frac464 = 0.0625 \
P(X=4) &= 0
endalign
$$



The expectation of $X$ is:



$$
mathrmE[X] = frac2464 + 2frac3664 + 3frac464 = frac2716 = 1.6875
$$



And the probability of having no woman at the table A is then:



$$
P(A=0) = frac3^34^3 = frac2764 = 0.421875
$$



Which complies with the result of method runMonteCarlo2.



Questions



  • Are my models correct?

  • For the given problem, what is the correct solution?









share|cite|improve this question











$endgroup$











  • $begingroup$
    It all depends on what you mean by "Then compute relevant quantities."
    $endgroup$
    – TonyK
    Mar 22 at 11:15











  • $begingroup$
    @TonyK Thank you for commenting, I have updated my question to address how do I compute those quantities.
    $endgroup$
    – jlandercy
    Mar 22 at 11:34










  • $begingroup$
    In your second solution, when you say you sample 3 numbers from 1,2,3,4, is that sampling with or without replacement? (In either case, your second solution seems suspect.)
    $endgroup$
    – awkward
    Mar 22 at 12:51













0












0








0


1



$begingroup$


Motivation



If have found my self answering to a SO question about Monte Carlo simulation. The model to design is stated as this:




Let 20 people, including exactly 3 women, seat themselves randomly at
4 tables (denoted A, B, C and D) of 5 persons each, with all arrangements
equally likely.



Let $X$ be the number of tables at which no women sit.
Write a Monte Carlo simulation to estimate the expectation of $E[X]$
and also estimate the probability $P(A=0)$ that no women sit at table A. Run
the simulation for 3 cases (100,1000,10000)




First, I drafted a first naïve solution, and then when refactorizing I changed the way possible inputs were drawn. I observed that solutions did not converged to the same quantities. Elements supporting this observation are available in my answer.



Implementations



First implementation



  • Create a vector of length $20$ populated as follow $(1,1,1,0,dots,0)$ where $1$ stands for a woman and $0$ for a man;

  • Draw a random permutation of this vector;

  • Assess the number of tables with no woman (splitting the vector into 4 tables);

Second implementation



  • Construct a set $S$ composed by $3$ numbers sampled from $1,dots,4$, it represents table where at least one woman sit with $0<#S<4$;

  • Here $X$ is simply assessed by $4 - #S$;

Quantities



Then, for each process, output are processed as follow:



  • Initialize empty Counters;

  • For each sample in $1,dots N$:

    • Draw an experiment and assess the value of $X$, this is where de difference lies;

    • Add $1$ to the modality $X=k$ in a dictionary of integer;

    • Add $1$ if table A is empty in an integer;


  • Rationalize counts with $N$ to get frequencies;

  • Assess the expected value $E[X]$;

Models



First implementation



I think the first implementation can be modeled as follow:



$$
#Omega = C^5_20C^5_15C^5_10C^5_5 = 11732745024
$$



With probabilities:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= frac4!3!fracC^1_3C^4_17C^1_3C^4_13C^1_3C^4_9C^5_5#Omega = frac2557 simeq 0.4386 \
P(X=2) &= frac4!2!fracC^1_3C^4_17C^2_2C^3_13C^5_10C^5_5#Omega = frac1019 simeq 0.5263 \
P(X=3) &= frac4!3!fracC^3_3C^2_17C^5_15C^5_10C^5_5#Omega = frac257 simeq 0.03509 \
P(X=4) &= 0
endalign
$$



Then the expected value is:



$$
mathrmE[X] = frac2557 + 2frac1019 + 3frac257 = frac9157 = 1.5965
$$



And the probability of having not a woman a table A is:



$$
P(A=0) = fracC^5_17#Omegaleft(
3 C^3_3C^2_12C^5_10C^5_5 +
6 C^1_3C^4_12C^2_2C^3_8C^5_5 +
C^1_3C^4_12C^1_2C^4_8C^1_1C^4_4
right) = frac91228 simeq 0.3991
$$



Which is compliant with results of method runMonteCarlo.



Second Implementation



And the second implementation can be modeled by a locker with 4 symbols (A, B, C, D) and 3 digits, then there is $# Omega = 4^3 = 64$ possible setups.



Then we can assess $P(X=k)$ using combinatorics:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= fracC^1_4 C^1_3 C^1_24^3 = frac2464 = 0.375 \
P(X=2) &= fracC^1_4 C^1_3 C^2_34^3 = frac3664 = 0.5625\
P(X=3) &= fracC^1_44^3 = frac464 = 0.0625 \
P(X=4) &= 0
endalign
$$



The expectation of $X$ is:



$$
mathrmE[X] = frac2464 + 2frac3664 + 3frac464 = frac2716 = 1.6875
$$



And the probability of having no woman at the table A is then:



$$
P(A=0) = frac3^34^3 = frac2764 = 0.421875
$$



Which complies with the result of method runMonteCarlo2.



Questions



  • Are my models correct?

  • For the given problem, what is the correct solution?









share|cite|improve this question











$endgroup$




Motivation



If have found my self answering to a SO question about Monte Carlo simulation. The model to design is stated as this:




Let 20 people, including exactly 3 women, seat themselves randomly at
4 tables (denoted A, B, C and D) of 5 persons each, with all arrangements
equally likely.



Let $X$ be the number of tables at which no women sit.
Write a Monte Carlo simulation to estimate the expectation of $E[X]$
and also estimate the probability $P(A=0)$ that no women sit at table A. Run
the simulation for 3 cases (100,1000,10000)




First, I drafted a first naïve solution, and then when refactorizing I changed the way possible inputs were drawn. I observed that solutions did not converged to the same quantities. Elements supporting this observation are available in my answer.



Implementations



First implementation



  • Create a vector of length $20$ populated as follow $(1,1,1,0,dots,0)$ where $1$ stands for a woman and $0$ for a man;

  • Draw a random permutation of this vector;

  • Assess the number of tables with no woman (splitting the vector into 4 tables);

Second implementation



  • Construct a set $S$ composed by $3$ numbers sampled from $1,dots,4$, it represents table where at least one woman sit with $0<#S<4$;

  • Here $X$ is simply assessed by $4 - #S$;

Quantities



Then, for each process, output are processed as follow:



  • Initialize empty Counters;

  • For each sample in $1,dots N$:

    • Draw an experiment and assess the value of $X$, this is where de difference lies;

    • Add $1$ to the modality $X=k$ in a dictionary of integer;

    • Add $1$ if table A is empty in an integer;


  • Rationalize counts with $N$ to get frequencies;

  • Assess the expected value $E[X]$;

Models



First implementation



I think the first implementation can be modeled as follow:



$$
#Omega = C^5_20C^5_15C^5_10C^5_5 = 11732745024
$$



With probabilities:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= frac4!3!fracC^1_3C^4_17C^1_3C^4_13C^1_3C^4_9C^5_5#Omega = frac2557 simeq 0.4386 \
P(X=2) &= frac4!2!fracC^1_3C^4_17C^2_2C^3_13C^5_10C^5_5#Omega = frac1019 simeq 0.5263 \
P(X=3) &= frac4!3!fracC^3_3C^2_17C^5_15C^5_10C^5_5#Omega = frac257 simeq 0.03509 \
P(X=4) &= 0
endalign
$$



Then the expected value is:



$$
mathrmE[X] = frac2557 + 2frac1019 + 3frac257 = frac9157 = 1.5965
$$



And the probability of having not a woman a table A is:



$$
P(A=0) = fracC^5_17#Omegaleft(
3 C^3_3C^2_12C^5_10C^5_5 +
6 C^1_3C^4_12C^2_2C^3_8C^5_5 +
C^1_3C^4_12C^1_2C^4_8C^1_1C^4_4
right) = frac91228 simeq 0.3991
$$



Which is compliant with results of method runMonteCarlo.



Second Implementation



And the second implementation can be modeled by a locker with 4 symbols (A, B, C, D) and 3 digits, then there is $# Omega = 4^3 = 64$ possible setups.



Then we can assess $P(X=k)$ using combinatorics:



$$
beginalign
P(X=0) &= 0 \
P(X=1) &= fracC^1_4 C^1_3 C^1_24^3 = frac2464 = 0.375 \
P(X=2) &= fracC^1_4 C^1_3 C^2_34^3 = frac3664 = 0.5625\
P(X=3) &= fracC^1_44^3 = frac464 = 0.0625 \
P(X=4) &= 0
endalign
$$



The expectation of $X$ is:



$$
mathrmE[X] = frac2464 + 2frac3664 + 3frac464 = frac2716 = 1.6875
$$



And the probability of having no woman at the table A is then:



$$
P(A=0) = frac3^34^3 = frac2764 = 0.421875
$$



Which complies with the result of method runMonteCarlo2.



Questions



  • Are my models correct?

  • For the given problem, what is the correct solution?






combinatorics random-variables monte-carlo






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Mar 22 at 16:07







jlandercy

















asked Mar 22 at 11:04









jlandercyjlandercy

261214




261214











  • $begingroup$
    It all depends on what you mean by "Then compute relevant quantities."
    $endgroup$
    – TonyK
    Mar 22 at 11:15











  • $begingroup$
    @TonyK Thank you for commenting, I have updated my question to address how do I compute those quantities.
    $endgroup$
    – jlandercy
    Mar 22 at 11:34










  • $begingroup$
    In your second solution, when you say you sample 3 numbers from 1,2,3,4, is that sampling with or without replacement? (In either case, your second solution seems suspect.)
    $endgroup$
    – awkward
    Mar 22 at 12:51
















  • $begingroup$
    It all depends on what you mean by "Then compute relevant quantities."
    $endgroup$
    – TonyK
    Mar 22 at 11:15











  • $begingroup$
    @TonyK Thank you for commenting, I have updated my question to address how do I compute those quantities.
    $endgroup$
    – jlandercy
    Mar 22 at 11:34










  • $begingroup$
    In your second solution, when you say you sample 3 numbers from 1,2,3,4, is that sampling with or without replacement? (In either case, your second solution seems suspect.)
    $endgroup$
    – awkward
    Mar 22 at 12:51















$begingroup$
It all depends on what you mean by "Then compute relevant quantities."
$endgroup$
– TonyK
Mar 22 at 11:15





$begingroup$
It all depends on what you mean by "Then compute relevant quantities."
$endgroup$
– TonyK
Mar 22 at 11:15













$begingroup$
@TonyK Thank you for commenting, I have updated my question to address how do I compute those quantities.
$endgroup$
– jlandercy
Mar 22 at 11:34




$begingroup$
@TonyK Thank you for commenting, I have updated my question to address how do I compute those quantities.
$endgroup$
– jlandercy
Mar 22 at 11:34












$begingroup$
In your second solution, when you say you sample 3 numbers from 1,2,3,4, is that sampling with or without replacement? (In either case, your second solution seems suspect.)
$endgroup$
– awkward
Mar 22 at 12:51




$begingroup$
In your second solution, when you say you sample 3 numbers from 1,2,3,4, is that sampling with or without replacement? (In either case, your second solution seems suspect.)
$endgroup$
– awkward
Mar 22 at 12:51










1 Answer
1






active

oldest

votes


















1












$begingroup$

Let me summarise the two ways of sampling. (1) Take a random (uniformly distributed) choice of a $3$-element subset of a $20$-element set, and for each of $4$ fixed disjoint subsets of those $20$ elements see whether at least one of their elements was chosen, then count the parts for which this was the case. (2) Take a random element of $1,2,3,4^3$ and count the number of distinct component values of the chosen triplet.



If the first method is done by selection without replacement of $3$ values among $20$, then the second can be done by a similar selection but with replacement, because you assume that for each item selection the probabilities for falling into each of the $4$ cases is equal, regardless of the values selected before. The two sampling procedure are not equivalent (the first method tends somewhat more to a balanced distribution) so it is not surprising the experimental results should be different. The first method directly models the stated problem, so it is the right one to use here.



The second method is easier to analyse, so I'll do that first. There are $4^3=64$ triplets, and simple enumeration will show that $4$ of them involve a single component value (repeated thrice), $36$ involve two component values (one of them repeated twice), and the remaining $24$ have three distinct component values (there are of course none that count no or all $4$ values as components). The more general problem of counting maps from an $n$-element set to an $m$-element set (of which this is an instance with $n=3$, $m=4$) by the size $k$ of the image set has as solution $binom mkk!leftnatop kright$ (where the last factor is a Stirling number of the second kind). The expected value of $X$ would be $frac2716=1.6875$.



For the first method there is one more parameter, the number $p$ of places per table (here $p=5$; the total number of places is $mp$). Doing some inclusion-exclusions gives the formula $binom mksum_i=0^k(-1)^k-ibinom kibinompin$ (which for the given values of the parameters gives values $40$, $600$, $500$ respectively for $k=1,2,3$, the three values adding up to $1140=binom203$, as they should. The expected value of $X$ (the correct one for the stated problem) works out to be $frac9157approx 1.5965$.






share|cite|improve this answer











$endgroup$













    Your Answer








    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3158013%2fchose-the-correct-inputs-for-a-monte-carlo-simulation%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$

    Let me summarise the two ways of sampling. (1) Take a random (uniformly distributed) choice of a $3$-element subset of a $20$-element set, and for each of $4$ fixed disjoint subsets of those $20$ elements see whether at least one of their elements was chosen, then count the parts for which this was the case. (2) Take a random element of $1,2,3,4^3$ and count the number of distinct component values of the chosen triplet.



    If the first method is done by selection without replacement of $3$ values among $20$, then the second can be done by a similar selection but with replacement, because you assume that for each item selection the probabilities for falling into each of the $4$ cases is equal, regardless of the values selected before. The two sampling procedure are not equivalent (the first method tends somewhat more to a balanced distribution) so it is not surprising the experimental results should be different. The first method directly models the stated problem, so it is the right one to use here.



    The second method is easier to analyse, so I'll do that first. There are $4^3=64$ triplets, and simple enumeration will show that $4$ of them involve a single component value (repeated thrice), $36$ involve two component values (one of them repeated twice), and the remaining $24$ have three distinct component values (there are of course none that count no or all $4$ values as components). The more general problem of counting maps from an $n$-element set to an $m$-element set (of which this is an instance with $n=3$, $m=4$) by the size $k$ of the image set has as solution $binom mkk!leftnatop kright$ (where the last factor is a Stirling number of the second kind). The expected value of $X$ would be $frac2716=1.6875$.



    For the first method there is one more parameter, the number $p$ of places per table (here $p=5$; the total number of places is $mp$). Doing some inclusion-exclusions gives the formula $binom mksum_i=0^k(-1)^k-ibinom kibinompin$ (which for the given values of the parameters gives values $40$, $600$, $500$ respectively for $k=1,2,3$, the three values adding up to $1140=binom203$, as they should. The expected value of $X$ (the correct one for the stated problem) works out to be $frac9157approx 1.5965$.






    share|cite|improve this answer











    $endgroup$

















      1












      $begingroup$

      Let me summarise the two ways of sampling. (1) Take a random (uniformly distributed) choice of a $3$-element subset of a $20$-element set, and for each of $4$ fixed disjoint subsets of those $20$ elements see whether at least one of their elements was chosen, then count the parts for which this was the case. (2) Take a random element of $1,2,3,4^3$ and count the number of distinct component values of the chosen triplet.



      If the first method is done by selection without replacement of $3$ values among $20$, then the second can be done by a similar selection but with replacement, because you assume that for each item selection the probabilities for falling into each of the $4$ cases is equal, regardless of the values selected before. The two sampling procedure are not equivalent (the first method tends somewhat more to a balanced distribution) so it is not surprising the experimental results should be different. The first method directly models the stated problem, so it is the right one to use here.



      The second method is easier to analyse, so I'll do that first. There are $4^3=64$ triplets, and simple enumeration will show that $4$ of them involve a single component value (repeated thrice), $36$ involve two component values (one of them repeated twice), and the remaining $24$ have three distinct component values (there are of course none that count no or all $4$ values as components). The more general problem of counting maps from an $n$-element set to an $m$-element set (of which this is an instance with $n=3$, $m=4$) by the size $k$ of the image set has as solution $binom mkk!leftnatop kright$ (where the last factor is a Stirling number of the second kind). The expected value of $X$ would be $frac2716=1.6875$.



      For the first method there is one more parameter, the number $p$ of places per table (here $p=5$; the total number of places is $mp$). Doing some inclusion-exclusions gives the formula $binom mksum_i=0^k(-1)^k-ibinom kibinompin$ (which for the given values of the parameters gives values $40$, $600$, $500$ respectively for $k=1,2,3$, the three values adding up to $1140=binom203$, as they should. The expected value of $X$ (the correct one for the stated problem) works out to be $frac9157approx 1.5965$.






      share|cite|improve this answer











      $endgroup$















        1












        1








        1





        $begingroup$

        Let me summarise the two ways of sampling. (1) Take a random (uniformly distributed) choice of a $3$-element subset of a $20$-element set, and for each of $4$ fixed disjoint subsets of those $20$ elements see whether at least one of their elements was chosen, then count the parts for which this was the case. (2) Take a random element of $1,2,3,4^3$ and count the number of distinct component values of the chosen triplet.



        If the first method is done by selection without replacement of $3$ values among $20$, then the second can be done by a similar selection but with replacement, because you assume that for each item selection the probabilities for falling into each of the $4$ cases is equal, regardless of the values selected before. The two sampling procedure are not equivalent (the first method tends somewhat more to a balanced distribution) so it is not surprising the experimental results should be different. The first method directly models the stated problem, so it is the right one to use here.



        The second method is easier to analyse, so I'll do that first. There are $4^3=64$ triplets, and simple enumeration will show that $4$ of them involve a single component value (repeated thrice), $36$ involve two component values (one of them repeated twice), and the remaining $24$ have three distinct component values (there are of course none that count no or all $4$ values as components). The more general problem of counting maps from an $n$-element set to an $m$-element set (of which this is an instance with $n=3$, $m=4$) by the size $k$ of the image set has as solution $binom mkk!leftnatop kright$ (where the last factor is a Stirling number of the second kind). The expected value of $X$ would be $frac2716=1.6875$.



        For the first method there is one more parameter, the number $p$ of places per table (here $p=5$; the total number of places is $mp$). Doing some inclusion-exclusions gives the formula $binom mksum_i=0^k(-1)^k-ibinom kibinompin$ (which for the given values of the parameters gives values $40$, $600$, $500$ respectively for $k=1,2,3$, the three values adding up to $1140=binom203$, as they should. The expected value of $X$ (the correct one for the stated problem) works out to be $frac9157approx 1.5965$.






        share|cite|improve this answer











        $endgroup$



        Let me summarise the two ways of sampling. (1) Take a random (uniformly distributed) choice of a $3$-element subset of a $20$-element set, and for each of $4$ fixed disjoint subsets of those $20$ elements see whether at least one of their elements was chosen, then count the parts for which this was the case. (2) Take a random element of $1,2,3,4^3$ and count the number of distinct component values of the chosen triplet.



        If the first method is done by selection without replacement of $3$ values among $20$, then the second can be done by a similar selection but with replacement, because you assume that for each item selection the probabilities for falling into each of the $4$ cases is equal, regardless of the values selected before. The two sampling procedure are not equivalent (the first method tends somewhat more to a balanced distribution) so it is not surprising the experimental results should be different. The first method directly models the stated problem, so it is the right one to use here.



        The second method is easier to analyse, so I'll do that first. There are $4^3=64$ triplets, and simple enumeration will show that $4$ of them involve a single component value (repeated thrice), $36$ involve two component values (one of them repeated twice), and the remaining $24$ have three distinct component values (there are of course none that count no or all $4$ values as components). The more general problem of counting maps from an $n$-element set to an $m$-element set (of which this is an instance with $n=3$, $m=4$) by the size $k$ of the image set has as solution $binom mkk!leftnatop kright$ (where the last factor is a Stirling number of the second kind). The expected value of $X$ would be $frac2716=1.6875$.



        For the first method there is one more parameter, the number $p$ of places per table (here $p=5$; the total number of places is $mp$). Doing some inclusion-exclusions gives the formula $binom mksum_i=0^k(-1)^k-ibinom kibinompin$ (which for the given values of the parameters gives values $40$, $600$, $500$ respectively for $k=1,2,3$, the three values adding up to $1140=binom203$, as they should. The expected value of $X$ (the correct one for the stated problem) works out to be $frac9157approx 1.5965$.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Mar 25 at 9:17

























        answered Mar 22 at 13:14









        Marc van LeeuwenMarc van Leeuwen

        88.8k5111230




        88.8k5111230



























            draft saved

            draft discarded
















































            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%2f3158013%2fchose-the-correct-inputs-for-a-monte-carlo-simulation%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