This file contains hidden or 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
| % https://tex.stackexchange.com/a/530909/194729 | |
| \makeatletter | |
| % \overarrow@ and \arrowfill@ are defined in amsmath | |
| \newcommand*{\overrightharpoonup}{\mathpalette{\overarrow@\rightharpoonupfill@}} | |
| \newcommand*{\overleftharpoonup}{\mathpalette{\overarrow@\leftharpoonupfill@}} | |
| \newcommand*{\rightharpoonupfill@}{\arrowfill@\relbar\relbar\rightharpoonup} | |
| \newcommand*{\leftharpoonupfill@}{\arrowfill@\leftharpoonup\relbar\relbar} |
This file contains hidden or 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
| using LinearAlgebra | |
| using Random | |
| using GaussianDistributions | |
| using GaussianDistributions: logpdf | |
| pair(u) = u[1], u[2] | |
| pair(p::Gaussian) = p.μ, p.Σ | |
| skiplast(r) = r[1:end-1] | |
| # time grid |
This file contains hidden or 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
| using WGLMakie, AbstractPlotting, FileIO | |
| WGLMakie.activate!() | |
| pl1 = WGLMakie.scatter(rand(10), rand(10)) | |
| using FileIO, AbstractPlotting, WGLMakie | |
| using WGLMakie.JSServe | |
| output = [] | |
| function save_plot(path::String, scene::Scene) | |
| return JSServe.with_session() do session, request | |
| three, canvas = WGLMakie.three_display(session, scene) |
This file contains hidden or 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 doi2bibtex(doi) | |
| url = startswith(doi, "http") ? doi : joinpath("https://doi.org/", doi) | |
| resp = HTTP.get(url, ["Accept"=>"application/x-bibtex; charset=utf-8"]; forwardheaders=true) | |
| strip(String(resp.body)) | |
| end |
This file contains hidden or 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
| using Colors | |
| using ColorVectorSpace | |
| using FileIO | |
| using REPL | |
| using ImageTransformations | |
| using ImageView | |
| @inline function inv_julia_map(z, c, n) | |
| ws = (1.0, exp(2/3*pi*im), exp(-2/3*pi*im)) | |
| ws[n]*(z - c)^(1/3) |
This file contains hidden or 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
| using JSServe, WGLMakie, AbstractPlotting | |
| using JSServe: JSServe.DOM, @js_str, onjs | |
| global three, scene | |
| using StaticArrays | |
| using Colors | |
| using Random | |
| rebirth(α, R) = x -> (rand() > α ? x : (2rand(typeof(x)) .- 1).*R) | |
| const 𝕏 = SVector |
This file contains hidden or 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
| using Plots, Interact, Base.Threads, BenchmarkTools | |
| # only called by resize. | |
| function batchify(maxIndex, numBatches) | |
| if mod(maxIndex, numBatches) == 0 | |
| n = numBatches | |
| else | |
| n = numBatches - 1 | |
| end | |
| batchSize = div(maxIndex, n) |
This file contains hidden or 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
| using LoopVectorization | |
| using Base.Threads | |
| function picalc_(r, a, b) | |
| su = 0.0 | |
| @avx for j in a:b | |
| su += 4.0/(1.0 + r[j]*r[j]) | |
| end | |
| su | |
| end |
This file contains hidden or 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
| t = 0:0.1:2pi+0.1 | |
| tslider, tau = textslider(1:200, "n", start = 1); | |
| lower = lift(tau) do i | |
| [Point3f0(.2cos(3s + i/10),0.0, 0.0) .+ (1 + 0.2sin(3s + i/10))*Point3f0(0, cos(s), sin(s)) for s in t] | |
| end | |
| upper = lift(tau) do i | |
| [Point3f0(-.2cos(3s + i/10),0.0, 0.0) .+ (1 - 0.2sin(3s + i/10)).*Point3f0(0, cos(s), sin(s)) for s in t] | |
| end | |
| hbox(tslider, band(lower, upper, color = [1.0:length(t)÷2; length(t)÷2:-1:1.0; length(t)÷2:-1:1.0; 1.0:length(t)÷2])) |
This file contains hidden or 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
| struct StoProMeasure | |
| θ::Float64 | |
| end | |
| struct WienerMeasure | |
| end | |
| function logdensity(P::StoProMeasure, tr, ::WienerMeasure) | |
| som = 0.0 | |
| t, x = tr |