Skip to content
New issue

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

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

Already on GitHub? # to your account

Make number of calls to consistent #32

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/core/mcs.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
function get_probdists_gtap_df(gtap, n=1000)
if gtap in ["highDF", "midDF", "lowDF"]
highDF = gtap_df_all[:, :, 3]
lowDF = gtap_df_all[:, :, 4]
midDF = gtap_df_all[:, :, 5]

highDF = gtap_df_all[:, :, 3]
lowDF = gtap_df_all[:, :, 4]
midDF = gtap_df_all[:, :, 5]

# For each region and temperature point we construct an interpolation where the x values are between 0 and 1
# and the y values are the values from the three scenarios.
dists = [LinearInterpolation([0.,0.5,1.], [lowDF[r,temp],midDF[r,temp], highDF[r,temp]]) for r in 1:16, temp in 1:3]
# For each region and temperature point we construct an interpolation where the x values are between 0 and 1
# and the y values are the values from the three scenarios.
dists = [LinearInterpolation([0.,0.5,1.], [lowDF[r,temp],midDF[r,temp], highDF[r,temp]]) for r in 1:16, temp in 1:3]

# We only sample one set of random numbers, as we want perfect correlation between all the individual
# parameter values.
samples = rand(TriangularDist(0., 1., 0.5), n)
# We only sample one set of random numbers, as we want perfect correlation between all the individual
# parameter values.
samples = rand(TriangularDist(0., 1., 0.5), n)

# Now evaluate the interpolated function we created above with the samples from the triangular distributions
sample_stores = [Mimi.SampleStore(dists[r,temp].(samples)) for r in 1:16, temp in 1:3]
# Now evaluate the interpolated function we created above with the samples from the triangular distributions
sample_stores = [Mimi.SampleStore(dists[r,temp].(samples)) for r in 1:16, temp in 1:3]

if gtap in ["highDF", "midDF", "lowDF"]
return sample_stores
else
@warn "No probability distributions available for gtap damage function entered ($gtap), returning `nothing`."
Expand Down
Loading