16. [R] Tutorial Jan 26

16. [R] Tutorial Jan 26 - x.old=4*mean(data.sim) x.old...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#alpha=.5 F.inv=function(x) sqrt(1+8*x)-2 data.sim = F.inv(runif(10000)) g=function(x) sum(data.sim/(1+data.sim*x)) g.der=function(x) -sum(data.sim^2/(1+data.sim*x)^2) ite=function(x) x-g(x)/g.der(x) x.old=3*mean(data.sim) x.old x.new=ite(x.old) n=1 while(abs(x.new-x.old)>1e-6){ x.old=x.new x.new=ite(x.old) n=n+1 } x.new n
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
#alpha=.5 F.inv=function(x) sqrt(1+8*x)-2 data.sim = F.inv(runif(10000)) g=function(x) sum(data.sim/(1+data.sim*x)) g.der=function(x) -sum(data.sim^2/(1+data.sim*x)^2) ite=function(x) x-g(x)/g.der(x)
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x.old=4*mean(data.sim) x.old x.new=ite(x.old) n=1 while(abs(x.new-x.old)>1e-6){ x.old=x.new x.new=ite(x.old) n=n+1 } x.new n #alpha=.5 F.inv=function(x) sqrt(1+8*x)-2 data.sim = F.inv(runif(10000)) g=function(x) sum(data.sim/(1+data.sim*x)) g.der=function(x)-sum(data.sim^2/(1+data.sim*x)^2) ite=function(x) x-g(x)/g.der(x) x.old=10*mean(data.sim) x.old x.new=ite(x.old) n=1 while(abs(x.new-x.old)>1e-6){ x.old=x.new x.new=ite(x.old) n=n+1 } x.new n...
View Full Document

Page1 / 3

16. [R] Tutorial Jan 26 - x.old=4*mean(data.sim) x.old...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online