Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extrapolation problem #753

Open
Vlad-Karpov opened this issue Aug 21, 2021 · 0 comments
Open

Extrapolation problem #753

Vlad-Karpov opened this issue Aug 21, 2021 · 0 comments

Comments

@Vlad-Karpov
Copy link

Hello
Can you help me?
I don't understand how to do that:

/**

  • y = Q1 * x + Q0
  • Q1=1/2
  • Q0=1/6
  • real data
  • x 1 2 3
  • y 4/6 7/6 10/6
  • suppose Q1 and Q0 unknown
  • and
  • input data (random observe)
  • x 1 2 3
  • y 1 1/2 2
  • need to find Q1 and Q0

*/
class LineEx {

val Q1: Uniform = Uniform(-10.0, 10.0)
val Q0: Uniform = Uniform(-10.0, 10.0)

val e1 = Normal(fx(Q1, Q0, 1.0), 0.5)
val e2 = Normal(fx(Q1, Q0, 2.0), 0.5)
val e3 = Normal(fx(Q1, Q0, 3.0), 0.5)

def fx(q1: Element[Double], q0: Element[Double], x: Double): Element[Double] = {
q1 * Constant(x) ++ q0
}

def resolve(): Array[Double] = {
e1.observe(1.0)
e2.observe(0.5)
e3.observe(2.0)
val likliHood = e1 * e2 * e3
val priorDistribution = Q1 * Q0
val mg = MetropolisHastings(ProposalScheme.default, likliHood * priorDistribution)
mg.start()
val r = Array(
mg.computeExpectation(Q1, (d: Double) => {
println(s"Q1=${d}")
d
}),
mg.computeExpectation(Q0, (d: Double) => {
println(s"Q0=${d}")
d
})
)
mg.stop()
mg.kill()
r
}

}

this code doesn't work

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant