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

Fix loglikelihood iterations #158

Merged
merged 1 commit into from
Feb 6, 2021
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
10 changes: 5 additions & 5 deletions src/cost_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ function (f::LogLikeLoss)(sol::DESolution)
ll = 0.0

if eltype(distributions) <: UnivariateDistribution
for j in 1:length(f.t), i in 1:length(sol[1][1])
for j in 1:length(f.t), i in 1:length(sol[1])
# i is the number of time points
# j is the size of the system
# corresponds to distributions[i,j]
ll -= logpdf(distributions[i,j],sol[i,j])
end
else # MultivariateDistribution
for j in 1:length(f.t), i in 1:length(sol[1][1])
for j in 1:length(f.t), i in 1:length(sol[1])
# i is the number of time points
# j is the size of the system
# corresponds to distributions[i,j]
Expand Down Expand Up @@ -218,7 +218,7 @@ function (f::LogLikeLoss)(sol::DiffEqBase.AbstractEnsembleSolution)
failure && return Inf
ll = 0.0
if eltype(distributions) <: UnivariateDistribution
for j in 1:length(f.t), i in 1:length(sol[1][1])
for j in 1:length(f.t), i in 1:length(sol[1])
# i is the number of time points
# j is the size of the system
# corresponds to distributions[i,j]
Expand All @@ -230,7 +230,7 @@ function (f::LogLikeLoss)(sol::DiffEqBase.AbstractEnsembleSolution)
# i is the number of time points
# j is the size of the system
# corresponds to distributions[i,j]
vals = [s[i,j] for i in 1:length(sol[1][1]), s in sol]
vals = [s[i,j] for i in 1:length(sol[1]), s in sol]
ll -= loglikelihood(distributions[j],vals)
end
end
Expand All @@ -245,7 +245,7 @@ function (f::LogLikeLoss)(sol::DiffEqBase.AbstractEnsembleSolution)
end
else
for j in 2:length(f.t)
vals = [s[i,j] - s[i,j-1] for i in 1:length(sol[1][1]), s in sol]
vals = [s[i,j] - s[i,j-1] for i in 1:length(sol[1]), s in sol]
fdll -= logpdf(distributions[j-1],vals)[1]
end
end
Expand Down