Currently browsing author

Andrew van der Westhuizen

Command-line progress bar

[================> ] 33% I frequently need a progress bar for applications, in order to visualize what is going on in the application. Below is a Java implementation of one. private static int lastPercent; public static void updatePercentageBar(float progress) { int percent = (int) Math.round(progress * 100); if (Math.abs(percent – lastPercent) …

FNV Hash in Java

The need for this function cropped up again. This time I in Java. Below is an implementation for 64bit as well as 32bit. public final class FNVHash { private static final long FNV_64_INIT = 0xcbf29ce484222325L; private static final long FNV_64_PRIME = 0x100000001b3L; private static final int FNV_32_INIT = 0x811c9dc5; private …

Marsaglia transform

Park Miller distributions

I have posted previously about the Park Miller method for generating uniform random numbers. This post is about visualising the distribution and any modifications of the .random() function. The histographer is used to visualise the distribution and estimate the descriptive statistics. The default ParkMiller.random() uniform distribution is shown first. Thereafter …