Created
November 17, 2018 16:02
-
-
Save mkim0710/8f4c32d8bab04ad5a6b1ecb0a89aeadb to your computer and use it in GitHub Desktop.
PDF and CDF of t-distribution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.facebook.com/groups/632755063474501/?multi_permalinks=1910139775736017¬if_id=1542238311570480¬if_t=group_highlights&ref=notif | |
t.pdf <- function(t,v){ | |
y <- GAM((v+1)/2)/sqrt(v*pi*GAM(v/2)^2)*(1+t^2/v)^(-(v+1)/2) | |
return(y) | |
} | |
t.cdf <- function(b,n,t.pdf,v){ | |
x <- seq(0,b,length=n)[2:(n-1)] | |
m <- length(x) | |
odd <- seq(1,m,2) | |
odd.sum <- 0 | |
even <- seq(2,m,2) | |
even.sum <- 0 | |
for(j in odd) { | |
odd.sum <- odd.sum + t.pdf(x[j],v) | |
} | |
for(k in even){ | |
even.sum <- even.sum+t.pdf(x[k],v) | |
} | |
i <- (b) * (t.pdf(0,v)+4*odd.sum+2*even.sum+t.pdf(b,v))/(3*n) | |
return(round(i,4)+0.5) | |
} | |
t.cdf(3,100000,t.pdf,100) | |
?GAM | |
??GAM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment