```
#define a vector
> X <- 0:10
>
>
> #define the probability
> PDF <- dbinom(x, 10, .408)
# I calculated the formula give in instruction #2 fx(x)= 3/x^4,x > 1 ( is this correct
>
> #adding the sum code for the PDF
> sum(PDF)
[1] 1
>
>
> #not sure if this is the proper format of inputting the PDF given in the HW file
> f <- function(x) 3/ ((x^2), (x > 1))
>g <- function(x) x*f(x)
>h <- function(x) x^4 * f(x)
> #it gives an error when I run it.
>
>
> #compute E(x)
> EX <- sum(x*PDF);
> EX
[1] 4.08
>
> #computing the variance
> varX <- sum((X-EX)^2*PDF)
>
> #computing
> EX <- integrate(h,
+ lower = 1,
+ upper = Inf)$value - (EX)^2
Error in match.fun(f) : object 'h' not found
# I have to calculate the expected value and variance of the fx(x) = 3/x^4, x > 1
```

# Expected value and variance of f(x) = 3/x^4, 1 < x < ∞

E(x) = ∫x*f(x)dx = ∫x*3*(x^-4)dx = ∫3*(x^-3)dx = 3*(x^-2)/(-2) = -1.5*(x^-2) = 1.5

E(x^2) = ∫(x^2)*f(x)dx = ∫(x^2) 3(x^-4)dx = ∫3*(x^-2)dx = 3*(x^-1)/(-1) = -3*(x^-1) = 3

Var(x) = E(x^2) - (E(x))^2 = 3 - 1.5^2 = .75

# E(x)

integrand <- function(x) {x*3*(x^-4)} # note that the two asterisks don't show up for some reason

Ex <- integrate(integrand, lower = 1, upper = Inf)

Ex$value

# E(x^2)

integrand <- function(x) {(x^2)*3*(x^-4)} # note that the two asterisks don't show up for some reason

Ex2 <- integrate(integrand, lower = 1, upper = Inf)

Ex2$value

Var = Ex2$value - (Ex$value)^2

Var

@fcas80, I think the intention in the homework problem is that the pdf is binomial and the f(x) functions are transformations. (But I could be wrong.) Also not clear to me, but maybe the support is 0 to 10, not to infinity.

Startz, good point. Let's hear from the original poster.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.