From a6568ee836ce2e077b345b855f3be4a24ed37fa5 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 26 Oct 2017 12:17:34 -0700 Subject: [PATCH] update parameter estimation and monte carlo --- docs/src/analysis/parameter_estimation.md | 10 +++++++--- docs/src/features/monte_carlo.md | 10 ++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/src/analysis/parameter_estimation.md b/docs/src/analysis/parameter_estimation.md index f46946e917..bcef44be6f 100644 --- a/docs/src/analysis/parameter_estimation.md +++ b/docs/src/analysis/parameter_estimation.md @@ -73,14 +73,18 @@ is a function which reduces the problem's solution. While this is very flexible, a two convenience routines is included for fitting to data: ```julia -L2DistLoss(t,data) -CostVData(t,data;loss_func = L2DistLoss) +L2DistLoss(t,data;weight=nothing) +CostVData(t,data;loss_func = L2DistLoss,weight=nothing) ``` where `t` is the set of timepoints which the data is found at, and `data` which are the values that are known. `L2DistLoss` is an optimized version of the L2-distance. In `CostVData`, one can choose any loss function from -LossFunctions.jl or use the default of an L2 loss. +LossFunctions.jl or use the default of an L2 loss. The `weight` is a vector +of weights for the loss function which must match the size of the data. + +Note that minimization of a weighted `L2DistLoss` is equivalent to maximum +likelihood estimation of a heteroskedastic Normally distributed likelihood. #### Note About Loss Functions diff --git a/docs/src/features/monte_carlo.md b/docs/src/features/monte_carlo.md index 14006264ff..8777fc6d7e 100644 --- a/docs/src/features/monte_carlo.md +++ b/docs/src/features/monte_carlo.md @@ -32,7 +32,7 @@ One can specify a function `prob_func` which changes the problem. For example: ```julia function prob_func(prob,i,repeat) - prob.u0 = randn()*prob.u0 + @. prob.u0 = randn()*prob.u0 prob end ``` @@ -45,7 +45,7 @@ you can have the `i`th simulation use the `i`th initial condition via: ```julia function prob_func(prob,i,repeat) - prob.u0 = u0_arr[i] + @. prob.u0 = u0_arr[i] prob end ``` @@ -279,8 +279,7 @@ and use that for calculating the trajectory: ```julia function prob_func(prob,i,repeat) - prob.u0 = rand()*prob.u0 - prob + ODEProblem(prob.f,rand()*prob.u0,prob.tspan) end ``` @@ -422,8 +421,7 @@ Our `prob_func` will simply randomize the initial condition: prob = ODEProblem((t,u)->1.01u,0.5,(0.0,1.0)) function prob_func(prob,i,repeat) - prob.u0 = rand()*prob.u0 - prob + ODEProblem(prob.f,rand()*prob.u0,prob.tspan) end ```