Let’s recap: a GUID is a 128 bit integer that is used as a globally unique identifier. GUIDs are not a security system; they do not guarantee uniqueness in a world where hostile parties are deliberately attempting to cause collisions; rather, they provide a cheap and easy way for mutually benign parties to generate identifiers…

# Tag: Mathematics

## The Solution To The Simple Puzzle

The first time I ran my histogram visualizer I asked for a Cauchy distribution with a minimum of -10 and a maximum of 10, and of course I got a graph that looks much like the one from my article of last week: Looks perfectly reasonable; I guess my program is correct right out…

## A Simple Puzzle

My original version of the histogram-generating code that I whipped up for the previous episode of FAIC contained a subtle bug. Can you spot it without going back and reading the corrected code? private static int[] CreateHistogram(IEnumerable<double> data, int buckets, double min, double max){ int[] results = new int[buckets]; double multiplier = buckets / (max…

## Generating Random Non-Uniform Data In C#

When building simulations of real-world phenomena, or when generating test data for algorithms that will be consuming information from the real world, it is often highly desirable to produce pseudo-random data that conform to some nonuniform probability distribution. But perhaps I have already lost some readers who do not remember STATS 101 all those years…

## Big head, long tail

Here’s a graph of the population size of the one hundred largest urban areas in Canada: (Click on the graph for a larger version.) Notice how there is an enormous spiky “head” on this graph: Toronto, Montreal and Vancouver are quite large cities by any measure. Then there is an immediate sharp drop to a…

## Murky Research

No computers today, but some interesting – and important – math. (And, happy Canada Day, Canadians!) “Car Talk” is a popular weekly phone-in program that has been on National Public Radio for several decades now, in which Bostonian brothers Tom and Ray crack wise and diagnose car (and relationship) problems. On many programs they feature a “puzzler”….

## Socks, birthdays and hash collisions

Suppose you’ve got a huge mixed-up pile of white, black, green and red socks, with roughly equal numbers of each. You randomly choose two of them. What is the probability that they are a matched pair? There are sixteen ways of choosing a pair of socks: WW, WB, WG, WR, BW, BB, … Of those…

## Long division

A thing that makes a reader go hmmm is why in C#, int divided by long has a result of long, even though it is clear that when an int is divided by a (nonzero) long, the result always fits into an int. I agree that this is a bit of a head scratcher. After…

## What exactly does ‘lifted’ mean?

(Note: all type placeholders S, T, U that I mention in this article are non-nullable value types.) I got a question the other day from a reader who had been taking a close look at the C# 2.0 standard. He noticed that when we talk about nullables in the standard we talk about “lifting”, but…

## Every Number Is Special In Its Own Special Way

I got a question recently about where in the .NET framework the “special numbers” were defined. The questioner was actually asking about the Double.NaN, Double.PositiveInfinity, etc, special values for floating point numbers. Of course there are other “special numbers” defined by the framework, such as Math.PI. The question was easily answered but it got me…