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
# Compute the nth elementary symmetric function (elementary symmetric polynomial) of a a 1D iterable x | |
# This is the THIRD esf | |
function esf(n, x) | |
summand = zero(eltype(x)) | |
for j1 = 1:n, j2 = 1:j1-1, j3 = 1:j2-1 | |
summand += x[j1]*x[j2]*x[j3] | |
end | |
return summand | |
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
#Problem-specific thing | |
dualitygap(x...) = nothing | |
solveeq(x...) = rand() | |
############################ | |
#Simple backtracking line search | |
function linesearch(v, dv, α₀= 1.0, δ = 0.6) | |
α = α₀ | |
while v + α*dv ≤ 0 |
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 CSV | |
using Nettle | |
using ZipFile | |
zfilename = download("http://files.grouplens.org/datasets/movielens/ml-20m.zip") | |
#TODO check hashes | |
#md5 = readchomp(open(download("http://files.grouplens.org/datasets/movielens/ml-20m.zip.md5"))) | |
#md5dl = open(zfilename) do f hexdigest(readall(f)) 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 Base: convert, rand, size, getindex, A_mul_B! | |
immutable PLINK1Matrix <: AbstractMatrix{UInt8} | |
m :: Int | |
n :: Int | |
data :: Array{UInt8} | |
end | |
size(M::PLINK1Matrix, i::Int) = i==1 ? M.m : i==2 ? M.n : error() | |
size(M::PLINK1Matrix) = (M.m, M.n) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
function randsubset(iterable, n::Int, T::Int=22) | |
state = start(iterable) | |
sample = eltype(iterable)[] | |
sizehint!(sample, n) | |
for j=1:n #Make first n record candidates for the sample | |
x, state = next(iterable, state) | |
done(iterable, state) && j<n && error("Requested sample of size $n but only $j items available") | |
push!(sample, x) | |
end | |
t = n #Number of records processed so far |
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
include("rankstability.jl") | |
info("Julia semantics") | |
axiomsused = Dict() | |
@axiom matmul Mat * Mat --> Mat | |
@axiom mattrans transpose(Mat) --> Mat | |
@axiom matdiv Mat / Mat --> Mat | |
@axiom matvec Mat * Vec --> Vec |
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
""" | |
Savitzky-Golay filter of window half-width M and degree N | |
M is the number of points before and after to interpolate, i.e. the full width | |
of the window is 2M+1 | |
""" | |
immutable SavitzkyGolayFilter{M,N} end | |
@generated function Base.call{M,N,T}(::Type{SavitzkyGolayFilter{M,N}}, | |
data::AbstractVector{T}) |
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
""" | |
estimate_coeffs | |
August, 2015 | |
Anna C. Gilbert | |
input: xs = samples of signal | |
Λ = list of (freq,coeff) pairs in current approx | |
Ω = list of (freq,coeff) pairs found in this iteration | |
k = length of short filter |