Skip to content

Commit

Permalink
Merge pull request #158 from SciML/ChrisRackauckas-patch-2
Browse files Browse the repository at this point in the history
Fix loglikelihood iterations
  • Loading branch information
ChrisRackauckas authored Feb 6, 2021
2 parents 1a2111c + db6fed4 commit 259f7ba
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 259f7ba

Please sign in to comment.