Question

How can I use R to enter a data set, along with the probability for each...

How can I use R to enter a data set, along with the probability for each data point, and find the expected values for each?

Homework Answers

Answer #1

Lets consider the random variable X taking value x=0,1,2,3,4,5 with respective probabilities p=0.1,0.2,0.3,0.1,0.2,0.1

### By using r command we enter the data set as follows.

> x=c(0,1,2,3,4,5)#####command to read value of random variable
> x
[1] 0 1 2 3 4 5
> p=c(0.1,0.2,0.3,0.1,0.2,0.1)#####command to read probabilities
> p
[1] 0.1 0.2 0.3 0.1 0.2 0.1
> cbind(x,p)#####command to make probability distribution table
x p
[1,] 0 0.1
[2,] 1 0.2
[3,] 2 0.3
[4,] 3 0.1
[5,] 4 0.2
[6,] 5 0.1
> sum(x*p)####command to obtain expected value
[1] 2.4
Since we know that the expected value of a random variable X is:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
How can I use R to compute a pooled sample covariance matrix and it's inverse? I...
How can I use R to compute a pooled sample covariance matrix and it's inverse? I am using the Bumpus Sparrows data set.
1. how to create residual vs. fitted plot in R ? (I know I can use...
1. how to create residual vs. fitted plot in R ? (I know I can use plot(), but I ONLY want one graph instead of four graphs created by plot(). ) 2.how to find outliers from a scatter plot in R? I need the code.
Use R to do each of the following. Use R code instructions that are as general...
Use R to do each of the following. Use R code instructions that are as general as possible, and also as efficient as possible. Use the Quick-R website for help on finding commands. 1. Enter the following values into a data vector named Dat: 45.4 44.2 36.8 35.1 39.0 60.0 47.4 41.1 45.8 35.6 2. Calculate the difference between the 2nd and 7th entries of this vector using only reference indices. 3. Calculate the median of Dat. 4. Sort the...
So, I am trying to perform a goodness of fit test on a set of data....
So, I am trying to perform a goodness of fit test on a set of data. The data consists of one thousand samples with values that range between 3.9 to 15.5. In the problem it is stated that this data could have either a gamma or normal distribution and I am meant to figure out which of these distributions it is closer to due to the results of two goodness of fit tests (one assuming gamma distribution and the other...
how to use aov commend in R Studio with only one column of data. the data...
how to use aov commend in R Studio with only one column of data. the data name is temperature for example. I know if there is two column of data i can use like avo(temperature~name, data=temperature), how to do it in one
You can use any data set Using the variables of interest, create a chart in R...
You can use any data set Using the variables of interest, create a chart in R (use ggplot library). This chart should be able to present to the reader what the relationship between the two variables are. If should answer, or hint towards an answer, to your question.
Consider the data set. 2,3,4,6,9 (a) Find the range. (Enter an exact number.) (b) Use the...
Consider the data set. 2,3,4,6,9 (a) Find the range. (Enter an exact number.) (b) Use the defining formula to compute the sample standard deviation s. (Enter a number. Round your answer to two decimal places.)
Calculate the probability weighted expected return for each asset along with the probability weighted standard deviation...
Calculate the probability weighted expected return for each asset along with the probability weighted standard deviation for each asset using the information below. What is the market risk premium? Please show work so I can understand how answer was reached. Thanks. State of Economy 1 2 3 4 Probability 0.13 0.4 0.3 0.17 T-bill 1.4% 1.5% 1.7% 1.6% S&P 500 7.5% 9.41% 18.5% 14.17%
Using R or RStudio After loading the data crime2005 data set from the library smss, use...
Using R or RStudio After loading the data crime2005 data set from the library smss, use (non-robust) linear regression to model the crime rate per 10,000 people (VI2) as a function of the percentage of the population that live in metropolitan areas (ME) and the percentage of the population that live below the poverty line (PO). Enter your R code below.
Construct a scattergram for each data set. Then calculate r and r2for each data set. Interpret...
Construct a scattergram for each data set. Then calculate r and r2for each data set. Interpret their values. Complete parts a through d. a. x−1,0,1,2,3 y−3,0,1,4,5 Calculate r. r=.9853 ​(Round to four decimal places as​ needed.)Calculate r2.=0.9709 ​(Round to four decimal places as​ needed.) Interpret r. Choose the correct answer below. A. There is not enough information to answer this question. B. There is a very strong negative linear relationship between x and y. C.x and y are not related....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT