Question

In: Math

This question involves coding in RStudio Problem 3 (Verzani problem 2.22): Write a function to compute...

This question involves coding in RStudio Problem 3 (Verzani problem 2.22):

Write a function to compute the average distance from the mean for some data vector.

Solutions

Expert Solution

X=c(299.87,100.85,108.91,203.24,204.91,200.19,247.11,145.11,330.33,94.33,
127.96,117.64,109.11,114.79,186.3,210.07,125.62,302.74,185.36,280.55,548.58,
174.12,285.37,66.24,262.09,89.59,150.58,311.13,57.54,125.64,125.86)

# Mean of the variable X

Mean=mean(X)
Mean

## The distance of each value from that mean

Y=abs(Mean-X)
Y

## The mean of those distances

Mean_distance=mean(Y)
Mean_distance

############# RUN ###########

> X=c(299.87,100.85,108.91,203.24,204.91,200.19,247.11,145.11,330.33,94.33,
+ 127.96,117.64,109.11,114.79,186.3,210.07,125.62,302.74,185.36,280.55,548.58,
+ 174.12,285.37,66.24,262.09,89.59,150.58,311.13,57.54,125.64,125.86)
>
> # Mean of the variable X
>
> Mean=mean(X)
> Mean
[1] 190.0558
>
> ## The distance of each value from that mean
>
> Y=abs(Mean-X)
> Y
[1] 109.814194 89.205806 81.145806 13.184194 14.854194 10.134194
[7] 57.054194 44.945806 140.274194 95.725806 62.095806 72.415806
[13] 80.945806 75.265806 3.755806 20.014194 64.435806 112.684194
[19] 4.695806 90.494194 358.524194 15.935806 95.314194 123.815806
[25] 72.034194 100.465806 39.475806 121.074194 132.515806 64.415806
[31] 64.195806
>
> ## The mean of those distances
>
> Mean_distance=mean(Y)
> Mean_distance
[1] 78.41642


Related Solutions

This question involves coding in RStudio Problem 3 (Verzani problem 8.18): The data set normtemp (Data...
This question involves coding in RStudio Problem 3 (Verzani problem 8.18): The data set normtemp (Data set can be found in the UsingR package) contains measurements of 130 healthy, randomly selected individuals. The variable temperature contains normal body temperature. Does the data appear to come from a normal distribution? Is so, find a 90% confidence interval for the mean normal body temperature of the population that was sampled. Does it include 98.6 degrees Fahrenheit?
Problem 3 Write code in R or Rstudio (Programming) A prime number is an integer greater...
Problem 3 Write code in R or Rstudio (Programming) A prime number is an integer greater than one whose only factors are one and itself. For example, the first ten prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29. A twin prime is a prime that has a prime gap of two. Sometimes the term twin prime is used for a pair of twin primes. For example, the five twin prime pairs are (3, 5),...
I have a python coding question: Write the function: eAapproximately (n), that takes a positive integer...
I have a python coding question: Write the function: eAapproximately (n), that takes a positive integer value n and returns an approximation of e as (1 + 1/n)^n I am not even sure what the question is asking me to do but I think it is asking me to code that function. Does anyone know how to do this?
Problem 3: Minimum In this problem, we will write a function to find the smallest element...
Problem 3: Minimum In this problem, we will write a function to find the smallest element of a list. We are, in a sense, reinventing the wheel since the min() function already performs this exact task. However, the purpose of this exercise is to have you think through the logic of how such a function would be implemented from scratch. Define a function named minimum(). The function should accept a single parameter named x, which is expected to be a...
Language: Python 3 (Please structure answer as basic as possible) Write a function that involves two...
Language: Python 3 (Please structure answer as basic as possible) Write a function that involves two arguments, named changeTheCase(myFile, case), that takes, as arguments, the name of a file, myFile, and the case, which will either be “upper” or “lower”. If case is equal to “upper” the function will open the file, convert all characters on each line to upper case, write each line to a new file, named “upperCase.txt”, and return the string “Converted file to upper case.” If...
Question 3: Transcription and Translation Below is the beginning of the coding strand of the protein-coding...
Question 3: Transcription and Translation Below is the beginning of the coding strand of the protein-coding region of the Cdc7 gene in yeast. Note that only the coding strand of the DNA is shown. Please be sure to correctly label the ends of any DNA, RNA or protein sequence written below. 5’ATGACAAGCAAAACGAAGAATATCGATGATATACCTCCAGAAATCAAAGAAGAGATGA TACAGCTCTATCATGATCTACCGGGTATAGAAAATGAATATAAACTCATAGACAAGATC GGTGAGGGAACATTTTCGTCAGTGTATAAAGCCAAAGATATCACTGGGAAAATAATAG3’ A. What is the sequence of the first 10 nucleotides of the template strand? B. What is the sequence of the first 10 nucleotides of the...
Python Problem 3 Write a function named enterNewPassword. This function takes no parameters. It prompts the...
Python Problem 3 Write a function named enterNewPassword. This function takes no parameters. It prompts the user to enter a password until the entered password has 8-15 characters, including at least one digit. Tell the user whenever a password fails one or both of these tests.
Using python as the coding language please write the code for the following problem. Write a...
Using python as the coding language please write the code for the following problem. Write a function called provenance that takes two string arguments and returns another string depending on the values of the arguments according to the table below. This function is based on the geologic practice of determining the distance of a sedimentary rock from the source of its component grains by grain size and smoothness. First Argument Value Second Argument Value Return Value "coarse" "rounded" "intermediate" "coarse"...
Use RStudio to answer this question. Before opening the dataset needed for this problem, you’ll need...
Use RStudio to answer this question. Before opening the dataset needed for this problem, you’ll need to call the “car” package > library(car) Now you can import the “Robey” dataset and use it to answer the question below. Name the data frame with abc: > abc <- Robey Remember to include any R code you use along with your answers! The Robey dataset contains fertility rates from a sample of countries. You want to see if total fertility rate (tfr),...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS)...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS) which works as a simple calculator. The program will get two integer numbers, and based on the requested operation, the result should be shown to the user. a. The program should print a meaningful phrase for each input, and the result. i. “Enter the first number” ii. “Enter the second number” iii. “Enter the operation type” iv. “The result is” b. The user should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT