-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update linear interpolation signature
- Loading branch information
Yi Zhang
committed
Nov 14, 2024
1 parent
6fb6f1a
commit f8b1698
Showing
2 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
data{ | ||
int nObs; | ||
array[nObs] real xObs; | ||
array[nObs] real yObs; | ||
int nx; | ||
int nPred; | ||
array[nPred] real xPred; | ||
} | ||
|
||
transformed data{ | ||
real xmin = min(xObs); | ||
real xmax = max(xObs); | ||
} | ||
|
||
parameters{ | ||
array[nx] real y; | ||
real<lower = 0> sigma; | ||
simplex[nx - 1] xSimplex; | ||
} | ||
|
||
transformed parameters{ | ||
array[nObs] real yHat; | ||
array[nx] real x; | ||
|
||
x[1] = xmin; | ||
x[nx] = xmax; | ||
for(i in 2:(nx-1)) | ||
x[i] = x[i-1] + xSimplex[i-1] * (xmax - xmin); | ||
|
||
yHat = pmx_ln_interpolate(xObs, x, y); | ||
} | ||
|
||
model{ | ||
xSimplex ~ dirichlet(rep_vector(1, nx - 1)); | ||
y ~ normal(0, 25); | ||
yObs ~ normal(yHat, sigma); | ||
} | ||
|
||
generated quantities{ | ||
array[nPred] real yHatPred; | ||
array[nPred] real yPred; | ||
|
||
yHatPred = pmx_ln_interpolate(xPred, x, y); | ||
for(i in 1:nPred) | ||
yPred[i] = normal_rng(yHatPred[i], sigma); | ||
} |