KMP library for tensors #300

Merged
grinisrit merged 215 commits from feature/tensor-algebra into dev 2021-05-08 09:48:04 +03:00
Showing only changes of commit 51f084d28b - Show all commits

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