mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-02-10 01:05:56 +01:00
Edit Exercise11.rmd
This commit is contained in:
@@ -17,7 +17,7 @@ h <- function(x, a) {
|
|||||||
x >= a
|
x >= a
|
||||||
}
|
}
|
||||||
|
|
||||||
G <- function(x, a, k) {
|
G_inv <- function(x, a, k) {
|
||||||
a / (1 - x)^(1 / k)
|
a / (1 - x)^(1 / k)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ x1 <- rcauchy(n, 0, 1)
|
|||||||
p1 <- h(x1, a)
|
p1 <- h(x1, a)
|
||||||
|
|
||||||
# Importance sampling
|
# Importance sampling
|
||||||
x2 <- G(runif(n), a, k)
|
x2 <- G_inv(runif(n), a, k)
|
||||||
p2 <- f(x2) / g(x2, a, k) * h(x2, a)
|
p2 <- f(x2) / g(x2, a, k) * h(x2, a)
|
||||||
|
|
||||||
# Results (cat the results and the var of the estimators)
|
# Results (cat the results and the var of the estimators)
|
||||||
|
|||||||
Reference in New Issue
Block a user