Comments (1)
So it works fine, and here is the code:
using DifferentialEquations ,BenchmarkTools, StochasticDiffEq, DiffEqJump, Plots
struct AffectIndex{F1, F2}
affect_index!::F1
index::F2
end
function (p::AffectIndex)(integrator)
return p.affect_index!(integrator, p.index)
end
####
struct RateIndex{F1, F2}
rate_index::F1
index::F2
end
function (q::RateIndex)(u, p, t)
return q.rate_index(u, p, t, q.index)
end
function μ_SDE(du,u,p,t)
du .= p.μ
end
function σ_SDE(du,u,p,t)
du .= p.σ
end
function affect!(integrator)
κ = 0.5
N = length(integrator.u)
sort_u = sort(integrator.u)
F = range(0.0, 1, length = N)
draw_quantile = rand(2) # draw quantile on (0,1)
u_n = sort_u[findlast(q -> q <= draw_quantile[1], F.^κ)]
u_n_2 = sort_u[findlast(q -> q <= draw_quantile[2], F.^κ)]
integrator.u[integrator.u .== u_n] =
max(integrator.u[integrator.u .== u_n], integrator.u[integrator.u .== u_n_2])
end
p = (μ = 0.01, σ = 0.1, N = 5) # if all constant
T = 10.0 # maximum time length
x_iv = rand(p.N) # just draws from the inital condition
prob = SDEProblem(μ_SDE, σ_SDE, x_iv ,(0.0, T), p)
rate(u,p,t) = 0.2*p.N
jump = ConstantRateJump(rate,affect!)
jump_prob = JumpProblem(prob,DirectFW(),jump)
sol = solve(jump_prob, SRIW1());
plot(sol)
from knowledgediffusionsimulations.jl.
Related Issues (20)
- Initial condition parameterization HOT 3
- Debug the parallelization issues with the ensemble
- Double-check that we think the moment data is being used correctly by the ensembles HOT 1
- A few more tweaks on the main one
- Try a picture with an ensemble but not looking at aggregated data HOT 1
- Debug the "Growth" calculations to make sure they are correct
- Fork the notebook for the variable jumps version HOT 12
- Calculation of the ergodic distirbution of growth rates HOT 2
- Test out Interact after seeing if other people fix the problems HOT 3
- Convert over to ribbon for the display. Right now we are dropping error bars HOT 5
- Investigate Variable Rate Results HOT 2
- Try conversion to closure approach HOT 1
- 8.14 Things to Check HOT 1
- Variable Rate HOT 1
- Sanity Check on ConstantRateJump Approximation to VariableRateJump HOT 1
- Create notebook with distorted draw distributions HOT 1
- Code to verify statistically growth rates with one vs. many jumps HOT 1
- Cleanup of the truncated brownian motion HOT 1
- General Code Cleanup HOT 1
- Front page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knowledgediffusionsimulations.jl.