Skip to content

Instantly share code, notes, and snippets.

@krv
krv / RALP
Created October 14, 2014 09:25
library(lpSolveAPI)
# Input
n <- 3 # n is cross-section
d <- 5 # number of worst case losses (based on the marginal; to be matched - dependence is unknown )
# simple example
# Create matrix with identical rows, filled with inverse probabilities
data <- matrix(1 : d,
ncol = n,
@krv
krv / gist:4667329
Created January 29, 2013 20:11
Wortels van vierkantsvergelijkingen oplossen, yay
(define (discriminant a b c)
(- (expt b 2) (* 4 a c)))
(define (wortel a b c)
(if (> (discriminant a b c) 0)
(list (/ (- (- b) (sqrt (discriminant a b c))) (* 2 a)) (/ (+ (- b) (sqrt (discriminant a b c))) (* 2 a)))
(if (= (discriminant a b c) 0)
(/ (- (- b)) (* 2 a))
"Imagine a solution")))
@krv
krv / gist:4650375
Created January 27, 2013 20:43
fropple
public void fropple() {
ListElement d = head;
int i = (getSize() % 2 == 0) ? getSize() : getSize() - 1;
while (i > 1) {
if (i-- % 2 == 0) {
Object temp = d.getFirst();
d.setValue(d.getNext().getFirst());
d.getNext().setValue(temp);
}
d = d.getNext();