Posts from May 2008.

5 simple rules for café trips

So yestoday Seph, Rune and me went to work. Apparently i came at the exact right moment, as the first question I was met with was “Hey, we talked about going to the downstairs café for brunch. You in?”.

Seeing as this is the thrid time we went down there in the last 3 weeks, we came up with a little ruleset for when we are allowed to ditch work, and have a relaxing cup of coffee.

Rules for café going for the Coniuro denmark office are:

  • If it’s very hot outside
  • If it’s very cold outside
  • If it’s very windy outside
  • If it became a habbit
  • If it has been a while since the last time we went

If any of the rules should become true, we are allowed to go.

Having an office in the center of copenhagen has it’s advantages!

Porting normalvariate from python to C

Seeing as bromer needed a normalvariate function in C for some cluster project at DIKU, I thought it might be a good deal of fun to port it from python. That plus I have no clue what so ever about what the function does.

Without further delay, here is my first C code for a long time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <math.h>
#include <stdlib.h>
 
#define NV_MAGICCONST 1.7155277699214135 /* (4 * exp(-0.5) / sqrt(2.0)); */
#define MAX_RANDOM 2147483647 /* (2 ** 31) - 1; */
 
/*
 * normalvariate ported from python's stdlib (random.normalvariate).
 * released under the same licence as that (python license).
 * 
 * remember to initialize the random engine before calling this function.
 */
double normalvariate(double mu, double sigma) {
	double u1, u2, z, zz;
	for (;;) {
		u1 = ((float)random()) / MAX_RANDOM;
		u2 = 1.0 - (((float)random()) / MAX_RANDOM);
 
		z = NV_MAGICCONST * (u1 - 0.5) / u2;
		zz = z * z / 4.0;
 
		if (zz <= -(log(u2))) {
			break;
		}
	}
 
	return mu + z * sigma;
}

Time pases

It seems it has been a while since I’ve written anything here. Well, I’ve been busy moving, painting, working and such. In deed, I’ve moved to my new home at Godsbanegade 18 which is about 5 minutes from work on a bicycle. Very, very nice. Also, my new place has a gas stove which I’m looking forward to start using. I’ve been showing it off to quite a few people but never actually used it yet.

Oh yes, and the new place is just about 250 meters away from Morten Reinholdt.

There, hope you feel updated now.