All pastes #625862 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-19 07:27 UTC
rendered paste body
    public static int[] rw(double p, int n, int steps) {
	int[] result = new int[n];
	int x=(Math.random()>.5)?-1:1;
        for (int t = 0; t < n; ++t) {
	    int sum = 0;
	    for (int i = 1; i < steps; ++i) {
		sum+=x;
                x = (Math.random()>p)?-x:x;
	    }
	    result[t]=sum;
	}
	return result;
    }