Currently browsing category

Code Snippets

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) …

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 …