This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.20.3 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
#! format: off | |
quote |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import numpy.typing as npt | |
def simulate(P:npt.NDArray, T:int, s0:int = 0) -> np.ndarray: | |
'Simulates with transition matrix P for T steps, starting at s0 = 0.' | |
u = np.random.uniform(0., 1., T) | |
S = np.empty(T, dtype = int) | |
S[0] = s0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.19.22 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
quote | |
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
""" | |
Compute the trajectory of a function f: (R^n x R) -> R^n, where x_{t + 1} = f(x_t, beta). | |
""" | |
def trajectory(f, beta, x0: np.ndarray, T: int) -> np.ndarray: | |
n = x0.shape[0] | |
X = np.zeros((T + 1, n), dtype = np.float64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# This function takes previous estimations of s(t) and generates a new RUNGE-KUTTA estimation based upon given timepoints | |
def NextApproximation(f, t, s, h): | |
k1 = f(t, s) | |
k2 = f(t + h/2, s + h*(k1/2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Pair" | |
function ↑(a::String, b::String) | |
a * '0' * b * a * '1' * b | |
end | |
""" | |
Unpair one step | |
""" | |
function ↓(p::String) | |
mid = length(p) ÷ 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
filename=$1 | |
echo "timeout --foreground 2h python3 $filename" | at 2300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function plotattractors(basins, attractors, x_space; kwargs...) | |
lims = extrema(x_space) | |
attractors_keys = keys(attractors) |> collect |> sort | |
isdivergent = -1 ∈ basins # Check whether there is a divergent region | |
isunique = length(unique(basins)) == 1 # Check whether the basin is uniform | |
levels = isdivergent ? [-1, attractors_keys..., Inf] : [attractors_keys..., Inf] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.16.4 | |
using Markdown | |
using InteractiveUtils | |
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). | |
macro bind(def, element) | |
quote | |
local el = $(esc(element)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
function plotvectorfield(xs, ys, g::Function; plotkwargs...) | |
fig = plot() | |
plotvectorfield!(fig, xs, ys, g; plotkwargs...) | |
return fig | |
end | |
function plotvectorfield!(figure, xs, ys, g::Function; rescale = 1, plotkwargs...) | |
xlims = extrema(xs) |
NewerOlder