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
pre <- scan() | |
51.11 | |
64.44 | |
73.33 | |
77.78 | |
66.67 | |
84.44 | |
68.89 | |
57.78 | |
64.44 |
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 <Python.h> | |
struct MyClass { | |
int val; | |
MyClass(void) : val(42) {} | |
}; | |
#ifdef __cplusplus | |
extern "C" { | |
#endif // __cplusplus |
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
# A wrapper around Rcartogram::cartogram for shape files. | |
# | |
# @param polys: Either a SpatialPolygonsDataFrame or the path to a shape file. | |
# @param variable: Either a string giving the name of the variable to used in polys@data, or a vector | |
# of the same length as polys@polygons. | |
# @param nx: The number of columns in the raster used to represent the region. | |
# @param ny: The number of rows in the raster used to represent the region. | |
# @param buffer.by: The proportion width of the buffer to add to the region (see ?Rcartogram::addBoundary). | |
# | |
# @return The new boundaries as A SpatialPolygonsDataFrame with the attribute 'cartogram.scaling.var'. |
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
test.func <- function(n.samples) { | |
nms <- c("Wichmann-Hill", "Marsaglia-Multicarry", "Super-Duper", "Mersenne-Twister", "Knuth-TAOCP-2002", "Knuth-TAOCP", "L'Ecuyer-CMRG") | |
tmp <- lapply(nms, function(unif.rng.name) { | |
RNGkind(unif.rng.name) | |
nms <- c("Kinderman-Ramage", "Ahrens-Dieter", "Box-Muller", "Inversion") | |
tmp <- sapply(nms, function(norm.rng.name) { | |
RNGkind(, norm.rng.name) | |
system.time(rnorm(n.samples)) | |
})[1:3,] | |
# included here because I'm not sure if rziggurat uses the unif rng internally. |
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
/* | |
Copyright (C) 2006 Anthony M. Pasqualoni | |
This program is free software; you can redistribute it and/or | |
modify it under the terms of the GNU General Public License | |
as published by the Free Software Foundation; either version 2 | |
of the License, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
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
/* | |
This program implements the BBP algorithm to generate a few hexadecimal | |
digits beginning immediately after a given position id, or in other words | |
beginning at position id + 1. On most systems using IEEE 64-bit floating- | |
point arithmetic, this code works correctly so long as d is less than | |
approximately 1.18 x 10^7. If 80-bit arithmetic can be employed, this limit | |
is significantly higher. Whatever arithmetic is used, results for a given | |
position id can be checked by repeating with id-1 or id+1, and verifying | |
that the hex digits perfectly overlap with an offset of one, except possibly | |
for a few trailing digits. The resulting fractions are typically accurate |
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
# Copyright (C) 2013 Simon Knapp | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the any terms you wish. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
# To run this, type: |
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
<html> | |
<!-- based example found at: http://blog.harakys.com/blog/2012/02/21/embed-markdown-into-your-html/ --> | |
<header> | |
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script> | |
<script src="https://google-code-prettify.googlecode.com/svn/loader/prettify.js"></script> | |
<script src="http://www.showdown.im/showdown/example/showdown.js"> </script> | |
<script type="text/javascript"> | |
var generateHTML = function() { |
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
opt.env <- new.env() | |
setOption <- function(auth_token, remaining_limit) { | |
cl <- as.list(match.call()[-1]) | |
invisible(mapply(assign, names(cl), cl, MoreArgs=list(envir=opt.env))) | |
} | |
getOption <- function(opt) if(exists(opt, envir=opt.env)) get(opt, envir=opt.env) else NA | |
#---- test --- |
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
# dummy data | |
maxN <- 10 | |
listLen <- 6 | |
Ns <- sample(as.integer(maxN/2):maxN, listLen) | |
dat <- lapply(Ns, function(N) data.frame(country=sample(maxN, N), var=rnorm(N))) | |
# function that (recursively) does the merging | |
merger <- function(lst, var.name) if(length(lst) == 1) lst else merge(lst[[1]], merger(lst[-1], var.name), by=var.name, all=T) | |
# do the merge and put sensible names on the result, and fix the NAs (set to zero) |
OlderNewer