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 <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
void r_message(std::string text) | |
{ | |
Rcpp::Function msg("message"); | |
msg(text); | |
} |
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 writeStuff(n) | |
f=open("data.txt","w") | |
for el in 1:n | |
r=randi(Int32) | |
println(f,r) | |
end | |
close(f) | |
end | |
N = 1000_000 |
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 <Rcpp.h> | |
// thanks to Simon for the macro magic | |
// problem #1: R internals uses "private" and "class" as | |
// member names. So a C++ compiler is confused | |
// when we include Connections.h | |
// this workaround uses the preprocessor to rename | |
// class as class_name and private as private_ptr | |
#define class class_name | |
#define private private_ptr |
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
package imagej; | |
import ij.*; | |
import ij.io.*; | |
import ij.process.*; | |
import java.io.*; | |
import javax.imageio.*; | |
import javax.imageio.stream.*; | |
import java.awt.image.BufferedImage; |
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
-- | |
require 'cudnn' | |
require 'cunn' | |
torch.setdefaulttensortype('torch.FloatTensor') | |
-- Get weight dim | |
function checkSums(rnn, seqLength, batch, inputDim, hiddenSize, layerNum, bidirectional) | |
rnn:reset() |
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
# load requisite libraries | |
library(shiny) | |
library(googleVis) | |
# load raw data (NB not provided) | |
tableByGame <- read.csv("../tableByGame.csv",stringsAsFactors=FALSE) | |
# to create chart need to repeat one column and get negative of league position as hack | |
tableByGame$game <- tableByGame$seasonGame | |
tableByGame$lgPos <- -tableByGame$lgPos |
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
num.iterations <- 1000 | |
# Download South African heart disease data | |
sa.heart <- read.table("http://www-stat.stanford.edu/~tibs/ElemStatLearn/datasets/SAheart.data", sep=",",head=T,row.names=1) | |
x <- sa.heart[,c("age", "ldl")] | |
y <- sa.heart$chd | |
plot(x, pch=21, bg=c("red","green")[factor(y)]) | |
# Function to standardize input values |
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
library(shiny) | |
library(ggplot2) | |
function(input, output) { | |
dataset <- reactive({ | |
diamonds[sample(nrow(diamonds), input$sampleSize),] | |
}) | |
output$plot <- renderPlot({ |
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
# Load the MNIST digit recognition dataset into R | |
# http://yann.lecun.com/exdb/mnist/ | |
# assume you have all 4 files and gunzip'd them | |
# creates train$n, train$x, train$y and test$n, test$x, test$y | |
# e.g. train$x is a 60000 x 784 matrix, each row is one digit (28x28) | |
# call: show_digit(train$x[5,]) to see a digit. | |
# brendan o'connor - gist.github.com/39760 - anyall.org | |
load_mnist <- function() { | |
load_image_file <- function(filename) { |
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
class DeBruijnGraph: | |
""" A de Bruijn multigraph built from a collection of strings. | |
User supplies strings and k-mer length k. Nodes of the de | |
Bruijn graph are k-1-mers and edges correspond to the k-mer | |
that joins a left k-1-mer to a right k-1-mer. """ | |
@staticmethod | |
def chop(st, k): | |
""" Chop a string up into k mers of given length """ | |
for i in xrange(0, len(st)-(k-1)): |
OlderNewer