This is a markdown file
```jlcon other stuff on this line
julia> 1+3 4
julia> error("oops") ERROR: oops in error at error.jl:21
# Figure 1 algorithm from http://icml2008.cs.helsinki.fi/papers/361.pdf | |
# project a real vector onto a simplex in nlogn time | |
# v is the vector to project | |
# z is the value to which the projected vector must sum, one by default | |
function projectsimplex{T <: Real}(v::Array{T, 1}, z::T=one(T)) | |
n=length(v) | |
µ = sort(v, rev=true) | |
#finding ρ could be improved to avoid so much temp memory allocation | |
ρ = maximum((1:n)[µ - (cumsum(µ) .- z) ./ (1:n) .> zero(T)]) | |
θ = (sum(µ[1:ρ]) - z)/ρ |
hdps_screen <- function(outcome, treatment, covars, keep=0, indexes=TRUE) { | |
#outcome and treatment are binary vectors of length n | |
#covars is a matrix of binary variabesl of size n x p, | |
# where p is the number of covariates for in a paritular data dimension | |
#keep: number of covariates to keep | |
# indexes: return indexes or subest of covars | |
# | |
#returns indexes of kept covariates or matrix of kept covars | |
#indexes are sorted by abs(log(multiplicitive bias)) | |
#if keep is 0 or greatner than the number of covars for which multiplicitive bias |
library(Rcpp) | |
cppFunction('NumericVector colVars(NumericMatrix x) { | |
int nrow = x.nrow(), ncol = x.ncol(); | |
NumericVector out(ncol); | |
for (int j = 0; j < ncol; j++) { | |
double mean = 0; | |
double M2 = 0; | |
int n; | |
double delta, xx; |
This is a markdown file
```jlcon other stuff on this line
julia> 1+3 4
julia> error("oops") ERROR: oops in error at error.jl:21
make_caret_wrappers <- function(alg_names) { | |
#creates an environment that stors SL wrappers. For a given <name> in alg_names, the wrapper will be | |
# named SL.caret.<name> | |
# alg_names should be a list of names of models provided by the caret pacakge. | |
# see http://caret.r-forge.r-project.org/modelList.html | |
# only set up for binomial family | |
# also, set up to use single split CV internally within caret. This can be changed by fiddling with fitControl, below | |
import Base.convert | |
bitstype 64 IBMFloat64 | |
# ibm float format is hex based: | |
# * bit 1 = sign | |
# * bits 2-8 = exponent to the power of 16, with bias of 64 | |
# * bits 9-64 = mantissa: no implied leading 1 (unlike ieee), | |
# typically normalised (hex of bits 9-12 is non-zero), though this need | |
# not be the case |
module firmod | |
type FIR{in_t,coef_t} | |
in::Vector{in_t} | |
coef::Vector{coef_t} | |
function FIR (coef::Vector{coef_t}) | |
new (zeros (in_t, size (coef)), copy (coef)) | |
end | |
end |