Question

Use R to answer the following questions: This problem will use R to find all possible...

Use R to answer the following questions: This problem will use R to find all possible orderings of 7 objects and probabilities associated with them. Consider your vector of possible values to be: values = as.character(1:7) (a) Use the function sample to draw from values 7 times (without replacement), and return this vector. Notice it is a vector, with 7 values. Display your particular draw. (b) Repeat (a) 100000 times using an sapply. Notice the result has 7 rows, and 100000 columns, where each column is a specific random draw. Use this result to find how many of your orderings begin with the character 1. (c) Use your samples from (b) to find the probability that a random ordering started with a 3 and ended with a 7. (d) The function paste can collapse a vector of many characters into a single character with the following command: one.order = paste(one.draw, collapse = "") Modify the above and use it with an sapply to find how many unique orderings of 7 values there are (assuming order matters and no repetitions are allowed).

Homework Answers

Answer #2

ANSWER::

a)

values = as.character(1:7)
s1<-sample(values)

s1 is

"7" "4" "1" "3" "6" "5" "2"

b)


t<-sapply(as.data.frame(replicate(100000,values)), sample)

#t is out dataset

> sum(t[1,]=="1")
[1] 14319

so 14319 start with 1

c)

> sum(t[1,] =='3' & t[7,]=='7')
[1] 2294

d)

one.order = apply(t,2, paste, collapse = "")
length(unique(one.order))

we get 5040 unique.

NOTE:: I HOPE YOUR HAPPY WITH MY ANSWER....***PLEASE SUPPORT ME WITH YOUR RATING...

***PLEASE GIVE ME "LIKE"...ITS VERY IMPORTANT FOR ME NOW....PLEASE SUPPORT ME ....THANK YOU

answered by: anonymous
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
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...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL R commands you used to reach your answers in a word or pdf document. Also, report everything you are asked to do so Problem 2 : Answer the following questions: 1. First run alphas <- seq(0.1, 1, by = 0.1) and nalphas <- - rev(alphas). Based on what you have seen, describe how functions seq and rev work. Then run qnorm(c(nalphas, alphas)) and report...
Part A: Answer all the questions below. You are required to number all your answers correctly...
Part A: Answer all the questions below. You are required to number all your answers correctly and write all the necessary solutions in your answer sheets. 1. If you would win $25 if you pulled a heart from a standard deck of 52 cards, the Expected Monetary Value would be? Write the implications if this bet is repeated a large number of times. [3 Marks] 2. Ifan8-characterPINisselectedfrom0,1,2,3,4,5,6,7,8,9,X,P,Rwhatisthetotal possible number of PINs without repetitions? [2 Marks] 3. How many total number...
For the following questions use the information given to find the probability. Write your answer as...
For the following questions use the information given to find the probability. Write your answer as a fraction or with a colon in lowest terms. A jar contains 3 red, 7 orange, and 2 blue marbles. If you pick one without looking, find the probability of drawing an orange marble. If you pick one without looking, find the probability of drawing a red or blue marble. If you pick one without looking, find the probability that the marble you draw...
Using R to solve the problem, please copy and paste your code. Thanks. (You must use...
Using R to solve the problem, please copy and paste your code. Thanks. (You must use R) 8. (15 pts) Consider the following questions: give the distribution name, carefully define the random variables you use and find the final answer. (a) (3 pts) A professor has made 20 exams of which 8 are hard, 7 are reasonable, and 5 are easy. The exams are mixed up and the professor selects 4 of them at random to give to four sections...
For each of the following questions, use Microsoft Excel to find the solution. Be sure to...
For each of the following questions, use Microsoft Excel to find the solution. Be sure to describe which functions you used and how you got the answer. Feel free to use whatever approach you want to get the right answer. Here are some functions you might find useful: BINOM.DIST POISSON.DIST HYPGEOM.DIST NORM.DIST Over the next 30 days, the pool has a 15% chance of closing each day. The closings are independent from each other. What is the probability that the...
*Answer all questions using R-Script* Question 1 Using the built in CO2 data frame, which contains...
*Answer all questions using R-Script* Question 1 Using the built in CO2 data frame, which contains data from an experiment on the cold tolerance of Echinochloa crus-galli; find the following. a) Assign the uptake column in the dataframe to an object called "x" b) Calculate the range of x c) Calculate the 28th percentile of x d) Calculate the sample median of x e) Calculate the sample mean of x and assign it to an object called "xbar" f) Calculate...
Question (2) [5 marks] (Use R) Suppose you have a company producing cupcakes. Each cupcake is...
Question (2) [5 marks] (Use R) Suppose you have a company producing cupcakes. Each cupcake is supposed to contain 10 grams of sugar. The cupcakes are produced by a machine that adds the sugar in a bowl before mixing everything. You believe the machine does not add 10 grams of sugar for each cupcake. If your assumption is true, the machine needs to be fixed. You stored the level of sugar of thirty cupcakes. Note: You can create a randomized...
Conducting a Simulation For example, say we want to simulate the probability of getting “heads” exactly...
Conducting a Simulation For example, say we want to simulate the probability of getting “heads” exactly 4 times in 10 flips of a fair coin. One way to generate a flip of the coin is to create a vector in R with all of the possible outcomes and then randomly select one of those outcomes. The sample function takes a vector of elements (in this case heads or tails) and chooses a random sample of size elements. coin <- c("heads","tails")...
Assignment Directions Answer the following critical thinking questions in this forum. Feel free to copy the...
Assignment Directions Answer the following critical thinking questions in this forum. Feel free to copy the questions and paste into your reply so that you cover each one. Use complete sentences and proper statistical terminology in all posts. Read the instructors response to the questions. Read the answers of some of your peers. Make a reply to your own post with any corrections to your responses. Read the answers of some of your peers and make a reply to at...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT