Question
Use R language. question 7

Q6. Hastings approximation: For 2 > 0, (z), the cdf of standard normal r.v., can be approximated by the function h(x) = 1 -
0 0
Add a comment Improve this question Transcribed image text
Answer #1

[1] phi at -1,0,1 [1] 0.1588762 [1] pnorm at -1,0,1 [1] 0.1586553 [1] Absolute difference: [1] 0.0002209108 [1] 2.20910

Code with comments

z=(x-mu)/sigma is used to convert it to standard normal distribution

z = Min 1 phi function(x,mu,sigma) { 2 (x-mu)/sigma 3 sign = z<0 #sign is negative 4. z = abs(z) #for using formula, z>=0 5 a

phi = function(x,mu,sigma) {
z = (x-mu)/sigma
sign = z<0 #sign is negative
z = abs(z) #for using formula, z>=0
a1=0.196854 #constants
a2=0.115194
a3=0.000344
a4=0.019527
h = 1-0.5*((1+a1*z+a2*z**2+a3*z**3+a4*z**4)**(-4)) #apply formula
if(sign){
h = 1-h #using normal distribution properties, area till -z is same as (1-area till z)
}
return(h)
}
print("phi at -1,0,1") #testing function
print(phi(-1,0,1))
print("pnorm at -1,0,1")
print(pnorm(-1,0,1))
print("Absolute difference: ")
diff = abs(pnorm(-1,0,1)-phi(-1,0,1))
print(diff)
format(diff, scientific=TRUE)

Add a comment
Know the answer?
Add Answer to:
Use R language. question 7 Q6. Hasting's approximation: For 2 > 0, "(z), the cdf of...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT