Intergral Calculation Websites
3 TV Purchases
# We have to write out the event space Sx and remember that the outcome possibilities are
# not much different than the dice example
pmf_tv = data.frame(x=c(0,400,750,800,1150,1500),px=c(.49,.168,.252,.0144,.0432,.0324))
pmf_tv$xpx = pmf_tv$x*pmf_tv$px
## Expected value
sum(pmf_tv$xpx)
## [1] 366
## Variance
pmf_tv$x2px = pmf_tv$x^2*pmf_tv$px
sum(pmf_tv$x2px) - sum(pmf_tv$xpx)^2
## [1] 173922
## standard deviation
sqrt(sum(pmf_tv$x2px) - sum(pmf_tv$xpx)^2)
## [1] 417.0396
4 Fabricating Plang
pmf_table = data.frame(x = c(0,1,2,3,4,5),px=c(.05,.1,.15,.25,.35,.1))
pmf_table$xpx = pmf_table$x*pmf_table$px
## Expected value
sum(pmf_table$xpx)
## [1] 3.05
## Variance
pmf_table$x2px = pmf_table$x^2*pmf_table$px
sum(pmf_table$x2px) - sum(pmf_table$xpx)^2
## [1] 1.7475
5 Equipment Lifetime
### This will return the Expected value of X or mean
ex_f = function(x) x*0.01*x*exp(-.1*x)
integrate(ex_f,lower=0,upper=Inf)
## 20 with absolute error < 8.1e-07
### This will return the Expected value of X^2
# see example 3.3-14
ex2_f = function(x) x^2*0.01*x*exp(-.1*x)
integrate(ex2_f,lower=0,upper=Inf)
## 600 with absolute error < 7e-04
# Now var(X) = E(X^2) - E(X)^2
integrate(ex2_f,lower=0,upper=Inf)$value - integrate(ex_f,lower=0,upper=Inf)$value^2
## [1] 200
7 Checkout Duration
### need the pdf from the cdf which is x/2
x7_f = function(x) (x*x)/2
integrate(x7_f,lower=0,upper=2)
## 1.333333 with absolute error < 1.5e-14
x27_f = function(x) (x^3)/2
integrate(x27_f,lower=0,upper=2)
## 2 with absolute error < 2.2e-14
# Now var(X) = E(X^2) - E(X)^2
integrate(x27_f,lower=0,upper=2)$value - integrate(x7_f,lower=0,upper=2)$value^2
## [1] 0.2222222
# The SD(X) is
sqrt(integrate(x27_f,lower=0,upper=2)$value - integrate(x7_f,lower=0,upper=2)$value^2)
## [1] 0.4714045