This commit is contained in:
Roland Grinis 2021-04-28 17:07:10 +01:00
parent a0e9180db6
commit 51f084d28b

View File

@ -30,20 +30,17 @@ fun main() {
println("Real alpha:\n$alpha") println("Real alpha:\n$alpha")
// also take sample of size 20 from normal distribution for x TODO rename // also take sample of size 20 from normal distribution for x
val x = randNormal( val x = randNormal(
intArrayOf(20, 5), intArrayOf(20, 5),
randSeed randSeed
) )
// calculate y and add gaussian noise (N(0, 0.05)) // calculate y and add gaussian noise (N(0, 0.05))
// TODO: please add an intercept: Y = beta * X + alpha + N(0,0.5)
val y = x dot alpha val y = x dot alpha
y += y.randNormalLike(randSeed) * 0.05 y += y.randNormalLike(randSeed) * 0.05
// now restore the coefficient vector with OSL estimator with SVD // now restore the coefficient vector with OSL estimator with SVD
// TODO: you need to change accordingly [X 1] [alpha beta] = Y
// TODO: inverting [X 1] via SVD
val (u, singValues, v) = x.svd() val (u, singValues, v) = x.svd()
// we have to make sure the singular values of the matrix are not close to zero // we have to make sure the singular values of the matrix are not close to zero