How can we find E(X^n) for a discrete random variable X in R?Random sample from given bivariate discrete distributionGrouping functions (tapply, by, aggregate) and the *apply familyDrop data frame columns by nameGenerate a random point within a circle (uniformly)How to make a great R reproducible exampleComputing SNR with discrete random variablescalculate mean and variance for weighted discrete random variables in RHow can I view the source code for a function?Discrete probability distribution with a given maximumCreate discrete random variables to find the probability that both events A and B happen
Drawing ramified coverings with tikz
Are the IPv6 address space and IPv4 address space completely disjoint?
Why did the HMS Bounty go back to a time when whales are already rare?
How do I color the graph in datavisualization?
If infinitesimal transformations commute why dont the generators of the Lorentz group commute?
Loading commands from file
How to explain what's wrong with this application of the chain rule?
Multiplicative persistence
Why did the EU agree to delay the Brexit deadline?
Open a doc from terminal, but not by its name
How much character growth crosses the line into breaking the character
Why electric field inside a cavity of a non-conducting sphere not zero?
Is the U.S. Code copyrighted by the Government?
Melting point of aspirin, contradicting sources
250 Floor Tower
Redundant comparison & "if" before assignment
How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?
Does a 'pending' US visa application constitute a denial?
What is this called? Old film camera viewer?
Approximating irrational number to rational number
What is Cash Advance APR?
Energy measurement from position eigenstate
Is it improper etiquette to ask your opponent what his/her rating is before the game?
Is it possible to put a rectangle as background in the author section?
How can we find E(X^n) for a discrete random variable X in R?
Random sample from given bivariate discrete distributionGrouping functions (tapply, by, aggregate) and the *apply familyDrop data frame columns by nameGenerate a random point within a circle (uniformly)How to make a great R reproducible exampleComputing SNR with discrete random variablescalculate mean and variance for weighted discrete random variables in RHow can I view the source code for a function?Discrete probability distribution with a given maximumCreate discrete random variables to find the probability that both events A and B happen
Suppose values of a discrete random variable X, randomNumbers
, and its distribution prob
is given.
I can find E(X) using the following code:
weighted.mean(randomNumbers, prob)
How can we find E(X^n) in R?
Would this code work?
weighted.mean(randomNumbers^n, prob)
r statistics probability weighted-average
add a comment |
Suppose values of a discrete random variable X, randomNumbers
, and its distribution prob
is given.
I can find E(X) using the following code:
weighted.mean(randomNumbers, prob)
How can we find E(X^n) in R?
Would this code work?
weighted.mean(randomNumbers^n, prob)
r statistics probability weighted-average
add a comment |
Suppose values of a discrete random variable X, randomNumbers
, and its distribution prob
is given.
I can find E(X) using the following code:
weighted.mean(randomNumbers, prob)
How can we find E(X^n) in R?
Would this code work?
weighted.mean(randomNumbers^n, prob)
r statistics probability weighted-average
Suppose values of a discrete random variable X, randomNumbers
, and its distribution prob
is given.
I can find E(X) using the following code:
weighted.mean(randomNumbers, prob)
How can we find E(X^n) in R?
Would this code work?
weighted.mean(randomNumbers^n, prob)
r statistics probability weighted-average
r statistics probability weighted-average
edited Mar 8 at 21:28
divibisan
5,03781834
5,03781834
asked Mar 8 at 4:44
user366312user366312
3,79946159319
3,79946159319
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Take Poisson random variable X ~ Poisson(2)
for example.
probabilistic method
f1 <- function (N)
x <- 0:N
p <- dpois(x, 2)
## approximate E[X]
m1 <- weighted.mean(x, p)
## approximate E[X ^ 2]
m2 <- weighted.mean(x ^ 2, p)
## approximate E[X ^ 3]
m3 <- weighted.mean(x ^ 3, p)
## return
c(m1, m2, m3)
As N
gets bigger, approximation is more and more accurate, in the sense that the sequence converges analytically.
N <- seq(10, 200, 10)
m123_prob <- t(sapply(N, f1))
matplot(m123_prob, type = "l", lty = 1)
statistical method (sampling based method)
f2 <- function (sample_size)
x <- rpois(sample_size, 2)
## unbiased estimate of E[x]
m1 <- mean(x)
## unbiased estimate of E[x ^ 2]
m2 <- mean(x ^ 2)
## unbiased estimate of E[x ^ 3]
m3 <- mean(x ^ 3)
## return
c(m1, m2, m3)
As sample_size
grows, estimation is more and more accurate, in the sense that the sequence converges in probability.
sample_size <- seq(10, 200, 10)
m123_stat <- t(sapply(sample_size, f2))
matplot(m123_stat, type = "l", lty = 1)
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056863%2fhow-can-we-find-exn-for-a-discrete-random-variable-x-in-r%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
Take Poisson random variable X ~ Poisson(2)
for example.
probabilistic method
f1 <- function (N)
x <- 0:N
p <- dpois(x, 2)
## approximate E[X]
m1 <- weighted.mean(x, p)
## approximate E[X ^ 2]
m2 <- weighted.mean(x ^ 2, p)
## approximate E[X ^ 3]
m3 <- weighted.mean(x ^ 3, p)
## return
c(m1, m2, m3)
As N
gets bigger, approximation is more and more accurate, in the sense that the sequence converges analytically.
N <- seq(10, 200, 10)
m123_prob <- t(sapply(N, f1))
matplot(m123_prob, type = "l", lty = 1)
statistical method (sampling based method)
f2 <- function (sample_size)
x <- rpois(sample_size, 2)
## unbiased estimate of E[x]
m1 <- mean(x)
## unbiased estimate of E[x ^ 2]
m2 <- mean(x ^ 2)
## unbiased estimate of E[x ^ 3]
m3 <- mean(x ^ 3)
## return
c(m1, m2, m3)
As sample_size
grows, estimation is more and more accurate, in the sense that the sequence converges in probability.
sample_size <- seq(10, 200, 10)
m123_stat <- t(sapply(sample_size, f2))
matplot(m123_stat, type = "l", lty = 1)
add a comment |
Take Poisson random variable X ~ Poisson(2)
for example.
probabilistic method
f1 <- function (N)
x <- 0:N
p <- dpois(x, 2)
## approximate E[X]
m1 <- weighted.mean(x, p)
## approximate E[X ^ 2]
m2 <- weighted.mean(x ^ 2, p)
## approximate E[X ^ 3]
m3 <- weighted.mean(x ^ 3, p)
## return
c(m1, m2, m3)
As N
gets bigger, approximation is more and more accurate, in the sense that the sequence converges analytically.
N <- seq(10, 200, 10)
m123_prob <- t(sapply(N, f1))
matplot(m123_prob, type = "l", lty = 1)
statistical method (sampling based method)
f2 <- function (sample_size)
x <- rpois(sample_size, 2)
## unbiased estimate of E[x]
m1 <- mean(x)
## unbiased estimate of E[x ^ 2]
m2 <- mean(x ^ 2)
## unbiased estimate of E[x ^ 3]
m3 <- mean(x ^ 3)
## return
c(m1, m2, m3)
As sample_size
grows, estimation is more and more accurate, in the sense that the sequence converges in probability.
sample_size <- seq(10, 200, 10)
m123_stat <- t(sapply(sample_size, f2))
matplot(m123_stat, type = "l", lty = 1)
add a comment |
Take Poisson random variable X ~ Poisson(2)
for example.
probabilistic method
f1 <- function (N)
x <- 0:N
p <- dpois(x, 2)
## approximate E[X]
m1 <- weighted.mean(x, p)
## approximate E[X ^ 2]
m2 <- weighted.mean(x ^ 2, p)
## approximate E[X ^ 3]
m3 <- weighted.mean(x ^ 3, p)
## return
c(m1, m2, m3)
As N
gets bigger, approximation is more and more accurate, in the sense that the sequence converges analytically.
N <- seq(10, 200, 10)
m123_prob <- t(sapply(N, f1))
matplot(m123_prob, type = "l", lty = 1)
statistical method (sampling based method)
f2 <- function (sample_size)
x <- rpois(sample_size, 2)
## unbiased estimate of E[x]
m1 <- mean(x)
## unbiased estimate of E[x ^ 2]
m2 <- mean(x ^ 2)
## unbiased estimate of E[x ^ 3]
m3 <- mean(x ^ 3)
## return
c(m1, m2, m3)
As sample_size
grows, estimation is more and more accurate, in the sense that the sequence converges in probability.
sample_size <- seq(10, 200, 10)
m123_stat <- t(sapply(sample_size, f2))
matplot(m123_stat, type = "l", lty = 1)
Take Poisson random variable X ~ Poisson(2)
for example.
probabilistic method
f1 <- function (N)
x <- 0:N
p <- dpois(x, 2)
## approximate E[X]
m1 <- weighted.mean(x, p)
## approximate E[X ^ 2]
m2 <- weighted.mean(x ^ 2, p)
## approximate E[X ^ 3]
m3 <- weighted.mean(x ^ 3, p)
## return
c(m1, m2, m3)
As N
gets bigger, approximation is more and more accurate, in the sense that the sequence converges analytically.
N <- seq(10, 200, 10)
m123_prob <- t(sapply(N, f1))
matplot(m123_prob, type = "l", lty = 1)
statistical method (sampling based method)
f2 <- function (sample_size)
x <- rpois(sample_size, 2)
## unbiased estimate of E[x]
m1 <- mean(x)
## unbiased estimate of E[x ^ 2]
m2 <- mean(x ^ 2)
## unbiased estimate of E[x ^ 3]
m3 <- mean(x ^ 3)
## return
c(m1, m2, m3)
As sample_size
grows, estimation is more and more accurate, in the sense that the sequence converges in probability.
sample_size <- seq(10, 200, 10)
m123_stat <- t(sapply(sample_size, f2))
matplot(m123_stat, type = "l", lty = 1)
answered Mar 8 at 5:45
李哲源李哲源
48.8k1498152
48.8k1498152
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55056863%2fhow-can-we-find-exn-for-a-discrete-random-variable-x-in-r%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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