Skip to content

Instantly share code, notes, and snippets.

View zenna's full-sized avatar

Zenna Tavares zenna

View GitHub Profile
@zenna
zenna / djalibuild.jl
Last active September 30, 2023 14:56
Build sequence
Utils
```jsx
sudo apt-get install -y curl clang locate libdrm-dev silversearcher-ag htop
```
**CUDA**
cuda 11.8
```jsx
@zenna
zenna / ciid.jl
Last active November 1, 2019 17:41
module MiniOmega
using Cassette
import Base:~
export sample, unif, pointwise, <|, rt
const ID = NTuple{N, Int} where N
"Ω is a hypercube"
struct Ω
using Omega
# Beta distributed random variables in [0, 1]
p1 = beta(0.5)
pgood = beta(0.5)
pbad = beta(0.5)
# Function that simulates the car
function simulate_car(ω)
car_is_good = Bernoulli(ω, p1(ω), Bool)
using Omega
# Add uncertainty to this if you want
region_size = 30_000
# The number of groups
ngroups = ciid-> Int(floor(uniform(ω, 1, region_size))))
# Produced random Boolean correlation matrix
function correlation_model(rng, nprobes = 10)
using Omega
# Add uncertainty to this if you want
region_size = 30_000
# The number of groups
ngroups = uniform(1:region_size)
# Produced random Boolean correlation matrix
function correlation_model(rng, nprobes = 10)
abstract type Node end
struct Val <: Node
x::Int
end
cons(::Val, x) = Val(x)
children(val::Val) = ()
struct Add{T1, T2} <: Node
@zenna
zenna / cata.jl
Last active April 3, 2019 05:19
Catamorphism
# Simplest Version
abstract type Node end
struct Val <: Node
x::Int
end
children(val::Val) = ()
@zenna
zenna / cond.jl
Last active March 25, 2019 22:07
using Omega
using Debugger
using Omega: mem
"Return sequence bounded between lb ad ub"
function f_(ω)
lb = -1.0
ub = 1.0
xs = Float64[]
x = rand(ω)
module MiniOmega
using Random
# Ω Subtypes Random.AbstractRNG to be compatible with existing samplers
mutable struct Ω <: Random.AbstractRNG
data::Dict{Int, Any} # Map ids to random values
i::Int # Current id
logscore::Float64
end
using Arrows
using NamedTuples
import JLD: load
# import Arrows.BenchmarkArrows: STD_ROTATION_MATRIX, render
import Images: colorview, Gray
using NamedTuples
const STD_ROTATION_MATRIX = [0.94071758 -0.33430171 -0.05738258
-0.33835238 -0.91297877 -0.2280076
0.02383425 0.2339063 -0.97196698]