Q: Help in understanding and solving this example from Data Structure & Algorithms (Computer Science) with the steps of the solution to better understand, thanks.
**Using R studio language, thanks.
R Lab:
You need to use R commands and using R markdown to generate a report that interacted with statistics R. A sample program is provided.
x =0:20 theta<-3 pdff<- (1/theta)*exp(-x/theta) cdff<- 1-exp(-x/theta) plot(x, pdff, type ='l')
Instructions:
1. Use R command to generate a sample of random numbers from the exponential distribution , with theta =5
a. You need to generate n =100*k, k is 8.
b. Generate the histogram of the random numbers generated, and overlaying it with the p.d.f of the exponential distribution.
So, the inverse of the exponential c.d.f is y=−θln(1−x), for 0≤x≤1
Based on the theorem in section 5.1 in the textbook, the algorithm for generating n varieties from an Exponential (θ
) distribution is:
Generate u1,...,un
n<-50 theta<-3 u<-runif(n,0,1) y<-(-theta)*log(1-u) x.range <- range(y) breaks <- seq(min(x.range),max(x.range),length=20) # Produce hist of the non drug measurements, then drug measurements on top hist(y, breaks=breaks, probability=TRUE, xlim=x.range, col="red") lines(breaks, dexp(breaks, rate = 1/3))
2.Your R markdown program should generate a report that shows the simulation process. Please send the report and your raw code.
a.In the report, you should draw the p.d.f. and c.d.f. of the exponential distribution.
b.You should add in your own conclusion on what you have observed in the histogram,
comparing it to the p.d.f. overlaying on it.
#Code Explained in comments:
QUESTION:1
#MUltiplication of x and y means :Adding x and x 'y' times
x <- 6 # Assign 6 value to x
y <- 7 #Assign 7 to y
cnt <-0 #Assign counter =0 for counting the loop purpose
sum <-0 #Intialise sum=0
while(cnt < y) #while counter<y it will add sum +x and stores
in sum ,increment the counter and by the end of the loop,sum
contains product of X AND y
{
sum=sum+x
cnt=cnt+1
}
print("Multiplication of x and y by addition concept:")#Displays
on console
print(sum) #Displays the product of x and y as sum vaiable on
console
//OUTPUT:
QUESTION:2(Divison by subtraction)
#Division of x and y means :Subtracting y from x untill x>=y
#suppose if we want to caluclate division of 43 by 7 ....If we subtract 7 from 43 --6 times the remainder will be 1 and quotient is how much times we subtracted y from x until x>=y i.e 6times
x <- 42 # Assign 42 value to x
y <- 7 #Assign 7 to y
print("x value :")
print(x)
print ("y value:")
print(y)
quotient <-0 #Intialise quotient=0 and used for couning
purpose about how much times we subtracted y from x for every
iteration
while(x>=y) #As discussed at the start of this answer described
we will run the loop satisfying condition x>=y
{
x=x-y
quotient=quotient+1 #increment the quotient counter by 1 for every
loop
}
print("Division of x and y by subtraction concept:")#Displays on console
print("QUOTIENT:")
print(quotient) #Displays the quotient vaiable on console
print("remainder:")
print(x) #displays remainder as current value of x
//OUTPUT:
Q: Help in understanding and solving this example from Data Structure & Algorithms (Computer Science) with...
info here is given to help solve #3 below this photo: You may use any computer software of your choice to complete this assignment Random variables from the four probability distributions given may be generated as follows 1. A standard uniform random variable, U in the interval (0,1), i.e., U ~ U (0,1), may be generated using the Matlab function 'rand'. The corresponding uniform random variable, X in the interval (-1,1) may be obtained as X 2U 1 2. A...
Solve d,e and f please using R code Part I: qqplots This part deals with qqplots of all kinds. Let's do some easy expe riments, first. Let's take a sample from a normal distribution with mu-2, sigma 3, and then look at the hist and the qqplot of that data: set.seed(3) n 100 # Sample size x norm(n,2,3) # Sample from N(mu-2, sigma-3) hist(x) # Looks normal. But that depends on breaks. qqnorm(x) # This doesn't depend on binsize, and...
Help with Q9 pls Q8 Q9 A pharmaceutical company has created a new drug to decrease how long patients suffer from a runny nose while having a cold. It is known that without treatment, on average, people report having a runny nose for 60 hours while having a cold. A test is organised for this new drug, hoping to prove the drug indeed decreases the duration of symptoms: 154 patients use it at the first sign of a runny nose...