All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.finmath.randomnumbers.HaltonSequence Maven / Gradle / Ivy

Go to download

finmath lib is a Mathematical Finance Library in Java. It provides algorithms and methodologies related to mathematical finance.

There is a newer version: 6.0.19
Show newest version
/*
 * (c) Copyright Christian P. Fries, Germany. Contact: [email protected].
 *
 * Created on 21 May 2018
 */
package net.finmath.randomnumbers;

/**
 * Implements a multi-dimensional Halton sequence (quasi random numbers) with the given bases.
 *
 * @author Christian Fries
 * @version 1.0
 */
public class HaltonSequence implements RandomNumberGenerator {

	private final int base[];

	private int currentIndex = 0;

	/**
	 * Constructs a Halton sequence with the given bases.
	 *
	 * The bases should be integers without common divisor greater than 1, for example, prime numbers.
	 *
	 * @param base The array of base integers. The length of the array defines the dimension of the sequence.
	 */
	public HaltonSequence(int[] base) {
		for(int i=0; i 0) {
			x += (index % base) * factor;
			factor /= base;
			index /= base;
		}

		return x;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy