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
# Public Domain | |
using LinearAlgebra: cross, dot, norm | |
""" | |
dihedral(r1, r2, r3, r4) | |
Compute the dihedral angle of two planes defined by (`r1`, `r2`, `r3`) and | |
(`r2`, `r3`, `r4`). |
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 f1() | |
function g() | |
x = 1 | |
return () -> x | |
end | |
x = 0 | |
h = g() | |
return h() | |
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
# Fattahi, Salar, and Somayeh Sojoudi. 2019. “Graphical Lasso and Thresholding: | |
# Equivalence and Closed-Form Solutions.” Journal of Machine Learning Research: | |
# JMLR. https://www.jmlr.org/papers/volume20/17-501/17-501.pdf. | |
function approxsol(Σ, λ) | |
# Residue of Σ relative to λ (see def. 11). | |
Σres = zeros(size(Σ)) | |
for j in axes(Σ, 2), i in axes(Σ, 1) | |
if i ≠ j && abs(Σ[i,j]) > λ | |
Σres[i,j] = Σ[i,j] - λ*sign(Σ[i,j]) | |
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
using LinearAlgebra | |
using Distributions | |
# Liu, Huan, Yongqiang Tang, and Hao Helen Zhang. 2009. “A New Chi-Square | |
# Approximation to the Distribution of Non-Negative Definite Quadratic Forms in | |
# Non-Central Normal Variables.” Computational Statistics & Data Analysis 53 | |
# (4): 853–56. | |
function genx2cdf(A, μ, Σ, t) | |
# k = 1 | |
AΣᵏ = A |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Static version of lowrankdowndate. | |
# The source code is derived from stdlib/LinearAlgebra/src/cholesky.jl. | |
# License is MIT (https://julialang.org/license) | |
using StaticArrays: SMatrix | |
using LinearAlgebra: LowerTriangular, PosDefException | |
""" | |
lowrankdowndate(L, v) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
using Base.Threads: @spawn, nthreads, threadid | |
N = 100 | |
chan = Channel(nthreads()) do chan | |
for val in 1:N | |
put!(chan, val) | |
println("T$(threadid()) => put $(val)") | |
end | |
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
using Random: default_rng, seed!, rand! | |
using RandomNumbers | |
using StaticArrays | |
#using Plots | |
#using BenchmarkTools | |
β_crit(q) = log(1 + √q) | |
rand_potts2d(q, m, n=m, rng=default_rng()) = rand(rng, Base.OneTo(Int8(q)), m, n) | |
function potts2d_ifelse!(q, s, β, niters, rng) |
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
using LinearAlgebra | |
function main() | |
# input data | |
train_data = read_data("./ml-100k/u.data") | |
n_user = length(unique([t[1] for t in train_data])) | |
n_item = length(unique([t[2] for t in train_data])) | |
# parameters | |
P, Q = fit(n_user, n_item, train_data) |
NewerOlder