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
| #= reparameterized truncated normal =# | |
| using Random | |
| using Zygote, Distributions, Plots, SpecialFunctions | |
| import Zygote: @adjoint, Numeric | |
| import Base.Broadcast: broadcasted | |
| """ | |
| ndtr(a) |
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 mix_dims(dims1, dims2, t) | |
| if in(t[1], dims2) | |
| return (1, mix_dims(dims1, Base.tail(dims2), Base.tail(t))...) | |
| else | |
| return (dims1[1], mix_dims(Base.tail(dims1), dims2, Base.tail(t))...) | |
| end | |
| end | |
| function mix_dims(dims1, dims2, t::Tuple{}) | |
| return () | |
| 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
| macro checked(fdef) | |
| d = splitdef(fdef) | |
| f = d[:name] | |
| args = d[:args] | |
| whereparams = d[:whereparams] | |
| d[:name] = gensym() | |
| shadow_fdef = combinedef(d) | |
| M = __module__ |
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
| pgrep -P 1 -u cossio # lists the PID of processes with PPID = 1 | |
| pgrep -P 1 -u cossio | xargs ps -p # prints the PID and some more info | |
| pgrep -P 1 -u cossio -f julia | xargs ps -o pid,ppid,command -p # print orphaned julia procs | |
| pgrep -P 1 -u cossio -f julia | xargs kill # kill them |
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
| (Proj) pkg> rm Sp┌ Error: Error in the keymap | |
| │ exception = | |
| │ type Nothing has no field ver | |
| │ Stacktrace: | |
| │ [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18 | |
| │ [2] __installed(::Pkg.Types.PackageMode) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:284 | |
| │ [3] complete_installed_package at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:773 [inlined] | |
| │ [4] complete_argument(::String, ::Int64, ::Int64, ::Pkg.REPLMode.CommandKind, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:821 | |
| │ [5] completions(::String, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:853 | |
| │ [6] complete_line(::Pkg.REPLMode.PkgCompletionProvider, ::REPL.LineEdit.PromptState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:761 |
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
| """midpoint of the interval [a,b]""" | |
| function midpoint(a::Float64, b::Float64) | |
| #= Based on F. Goualard. 2014, Table VII | |
| DOI: 10.1145/2493882 =# | |
| if !(a ≤ b) | |
| return NaN | |
| elseif a == -Inf | |
| if b == Inf | |
| return 0. |
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 Distributions | |
| n = 4969027388018185 | |
| p = [4.471459552709845e-5, | |
| 0.0021070048390116223, | |
| 0.0017485819413324416, | |
| 0.0022622153482103544, | |
| 0.0019479678673445784, | |
| 0.0015864519243622935, | |
| 0.00037279832670023585, |
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 findmaxkey(d::Dict) | |
| maxk,maxv = first(d) | |
| for k in keys(d) | |
| if d[k] > maxv | |
| maxk, maxv = k, d[k] | |
| end | |
| end | |
| return maxk=>maxv | |
| 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
| for i = 1:L, a = 1:A | |
| @assert sub2ind((A,L),a,i) == (i-1)*A + a | |
| end | |
| for j=1:L, i=1:L, b=1:A, a=1:A | |
| @assert sub2ind((A,A,L,L),a,b,i,j) == a + (b-1)*A + (i-1)*A*A + (j-1)*A*A*L | |
| end | |
| srand(2); | |
| L = rand(2:10); A = rand(2:10,L); |
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 dnacompl(nt::Char) | |
| @assert nt ∈ ('A', 'T', 'C', 'G', 'N', '*') | |
| if nt == 'A' | |
| return 'T' | |
| elseif nt == 'T' | |
| return 'A' | |
| elseif nt == 'G' | |
| return 'C' | |
| elseif nt == 'C' | |
| return 'G' |