Tossing 3 fair coins in R (2)Tossing 3 fair coins in RSolving statistics question using PythonSimulate coin toss for one week?Outcome of a simulated dice and coin toss in RCoin Toss game in RProbability - Coin TossingCalculating observed values from a coin-toss simulation in RDFA for expected coin tossesUnbiased coin toss of n coins with different success values for each coinImplementing Predictive Posterior Distribution Using StanTossing 3 fair coins in R

What does the "remote control" for a QF-4 look like?

Today is the Center

How do I deal with an unproductive colleague in a small company?

Perform and show arithmetic with LuaLaTeX

Do infinite dimensional systems make sense?

Java Casting: Java 11 throws LambdaConversionException while 1.8 does not

What defenses are there against being summoned by the Gate spell?

Why can't we play rap on piano?

Why doesn't H₄O²⁺ exist?

Replacing matching entries in one column of a file by another column from a different file

Does an object always see its latest internal state irrespective of thread?

Cross compiling for RPi - error while loading shared libraries

Codimension of non-flat locus

Maximum likelihood parameters deviate from posterior distributions

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

What is the word for reserving something for yourself before others do?

How old can references or sources in a thesis be?

Convert two switches to a dual stack, and add outlet - possible here?

infared filters v nd

How to format long polynomial?

What's the point of deactivating Num Lock on login screens?

Can a vampire attack twice with their claws using Multiattack?

Malformed Address '10.10.21.08/24', must be X.X.X.X/NN or

Has there ever been an airliner design involving reducing generator load by installing solar panels?



Tossing 3 fair coins in R (2)


Tossing 3 fair coins in RSolving statistics question using PythonSimulate coin toss for one week?Outcome of a simulated dice and coin toss in RCoin Toss game in RProbability - Coin TossingCalculating observed values from a coin-toss simulation in RDFA for expected coin tossesUnbiased coin toss of n coins with different success values for each coinImplementing Predictive Posterior Distribution Using StanTossing 3 fair coins in R






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2
















If X = # of heads showing when three coins are tossed, find P(X=1), and E(X).




The experiment has the following distribution:



enter image description here



According to my calculation,
P(X=1) = 0.375 ≈ 0.40
E(X) = 1.50



And, enter image description here



where n = # of repetitions of the experiment.



Source Code



noOfExperiments = 10000;
mySample <- sample(c(0,1,2,3), noOfExperiments, replace = T)
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount / noOfExperiments
eX <- sum(mySample)/noOfExperiments


According to the above code, I obtained
P(X=1) = 0.2518
E(X) = 1.4917 ≈ 1.50



It seems like the value of E(X) is coming well, but the value of P(X=1) is not coming correctly.



What is wrong with my code?



Edit:



enter image description here



I have written the following code on the basis of Edward Carney's comment.



noOfExperiments = 1000;
mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) )
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount/noOfExperiments
eX <- sum(mySample)/noOfExperiments


enter image description here




Note: related question.










share|improve this question



















  • 2





    An experiment would not involve inserting the probabilities ahead of time. A more realistic simulation can be obtained using mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) followed by table(mySample)/noOfExperiments `.

    – Edward Carney
    Mar 8 at 2:32






  • 3





    In your original code, you're not using the given probabilities at all - you could apply them using sample(c(0,1,2,3), noOfExperiments, replace = T, prob = c(0.125, 0.375, 0.375, 0.125))

    – Marius
    Mar 8 at 3:18

















2
















If X = # of heads showing when three coins are tossed, find P(X=1), and E(X).




The experiment has the following distribution:



enter image description here



According to my calculation,
P(X=1) = 0.375 ≈ 0.40
E(X) = 1.50



And, enter image description here



where n = # of repetitions of the experiment.



Source Code



noOfExperiments = 10000;
mySample <- sample(c(0,1,2,3), noOfExperiments, replace = T)
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount / noOfExperiments
eX <- sum(mySample)/noOfExperiments


According to the above code, I obtained
P(X=1) = 0.2518
E(X) = 1.4917 ≈ 1.50



It seems like the value of E(X) is coming well, but the value of P(X=1) is not coming correctly.



What is wrong with my code?



Edit:



enter image description here



I have written the following code on the basis of Edward Carney's comment.



noOfExperiments = 1000;
mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) )
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount/noOfExperiments
eX <- sum(mySample)/noOfExperiments


enter image description here




Note: related question.










share|improve this question



















  • 2





    An experiment would not involve inserting the probabilities ahead of time. A more realistic simulation can be obtained using mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) followed by table(mySample)/noOfExperiments `.

    – Edward Carney
    Mar 8 at 2:32






  • 3





    In your original code, you're not using the given probabilities at all - you could apply them using sample(c(0,1,2,3), noOfExperiments, replace = T, prob = c(0.125, 0.375, 0.375, 0.125))

    – Marius
    Mar 8 at 3:18













2












2








2


1







If X = # of heads showing when three coins are tossed, find P(X=1), and E(X).




The experiment has the following distribution:



enter image description here



According to my calculation,
P(X=1) = 0.375 ≈ 0.40
E(X) = 1.50



And, enter image description here



where n = # of repetitions of the experiment.



Source Code



noOfExperiments = 10000;
mySample <- sample(c(0,1,2,3), noOfExperiments, replace = T)
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount / noOfExperiments
eX <- sum(mySample)/noOfExperiments


According to the above code, I obtained
P(X=1) = 0.2518
E(X) = 1.4917 ≈ 1.50



It seems like the value of E(X) is coming well, but the value of P(X=1) is not coming correctly.



What is wrong with my code?



Edit:



enter image description here



I have written the following code on the basis of Edward Carney's comment.



noOfExperiments = 1000;
mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) )
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount/noOfExperiments
eX <- sum(mySample)/noOfExperiments


enter image description here




Note: related question.










share|improve this question

















If X = # of heads showing when three coins are tossed, find P(X=1), and E(X).




The experiment has the following distribution:



enter image description here



According to my calculation,
P(X=1) = 0.375 ≈ 0.40
E(X) = 1.50



And, enter image description here



where n = # of repetitions of the experiment.



Source Code



noOfExperiments = 10000;
mySample <- sample(c(0,1,2,3), noOfExperiments, replace = T)
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount / noOfExperiments
eX <- sum(mySample)/noOfExperiments


According to the above code, I obtained
P(X=1) = 0.2518
E(X) = 1.4917 ≈ 1.50



It seems like the value of E(X) is coming well, but the value of P(X=1) is not coming correctly.



What is wrong with my code?



Edit:



enter image description here



I have written the following code on the basis of Edward Carney's comment.



noOfExperiments = 1000;
mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) )
outcomeCount <- length(which(mySample==1))
prob <- outcomeCount/noOfExperiments
eX <- sum(mySample)/noOfExperiments


enter image description here




Note: related question.







r statistics probability






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 3:13







user366312

















asked Mar 8 at 1:52









user366312user366312

3,88046159319




3,88046159319







  • 2





    An experiment would not involve inserting the probabilities ahead of time. A more realistic simulation can be obtained using mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) followed by table(mySample)/noOfExperiments `.

    – Edward Carney
    Mar 8 at 2:32






  • 3





    In your original code, you're not using the given probabilities at all - you could apply them using sample(c(0,1,2,3), noOfExperiments, replace = T, prob = c(0.125, 0.375, 0.375, 0.125))

    – Marius
    Mar 8 at 3:18












  • 2





    An experiment would not involve inserting the probabilities ahead of time. A more realistic simulation can be obtained using mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) followed by table(mySample)/noOfExperiments `.

    – Edward Carney
    Mar 8 at 2:32






  • 3





    In your original code, you're not using the given probabilities at all - you could apply them using sample(c(0,1,2,3), noOfExperiments, replace = T, prob = c(0.125, 0.375, 0.375, 0.125))

    – Marius
    Mar 8 at 3:18







2




2





An experiment would not involve inserting the probabilities ahead of time. A more realistic simulation can be obtained using mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) followed by table(mySample)/noOfExperiments `.

– Edward Carney
Mar 8 at 2:32





An experiment would not involve inserting the probabilities ahead of time. A more realistic simulation can be obtained using mySample <- replicate(noOfExperiments, sum(sample(c(0, 1), 3, replace=T)) followed by table(mySample)/noOfExperiments `.

– Edward Carney
Mar 8 at 2:32




3




3





In your original code, you're not using the given probabilities at all - you could apply them using sample(c(0,1,2,3), noOfExperiments, replace = T, prob = c(0.125, 0.375, 0.375, 0.125))

– Marius
Mar 8 at 3:18





In your original code, you're not using the given probabilities at all - you could apply them using sample(c(0,1,2,3), noOfExperiments, replace = T, prob = c(0.125, 0.375, 0.375, 0.125))

– Marius
Mar 8 at 3:18












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55055625%2ftossing-3-fair-coins-in-r-2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • 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.

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%2fstackoverflow.com%2fquestions%2f55055625%2ftossing-3-fair-coins-in-r-2%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

AWS Lex not identifying response if by a variable 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) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович