diff --git a/Knot.files b/Knot.files
index a540a1ffcae22c431ab066ee991dfce28037411e..8110aac99d14da7786f9e5a47223b154a92de538 100644
--- a/Knot.files
+++ b/Knot.files
@@ -101,6 +101,8 @@ src/common/ref.h
 src/common/modified_tree.h
 src/common/general-tree.h
 src/common/general-tree.c
+src/common/WELL1024a.c
+src/common/WELL1024a.h
 src/zcompile/parser-descriptor.h
 src/zcompile/parser-descriptor.c
 src/zcompile/parser-util.h
diff --git a/libknot/Makefile.am b/libknot/Makefile.am
index 1829ea8daa18b97f3c262116cb863ce4be630b9f..75e97e1d9155b60a80f3cf4da54782a4638f6d55 100644
--- a/libknot/Makefile.am
+++ b/libknot/Makefile.am
@@ -41,7 +41,9 @@ libknot_common_SOURCES = \
 	common/ref.h				\
 	common/ref.c				\
 	common/errors.h				\
-	common/errors.c
+	common/errors.c				\
+	common/WELL1024a.h			\
+	common/WELL1024a.c
 
 libknot_la_SOURCES =				\
 	$(libknot_common_SOURCES)		\
diff --git a/src/Makefile.am b/src/Makefile.am
index c87f71aebf313ca663a32ee6c5f8e03f74bece39..e137bccdab6f68f1c24f8200df3de85b798710ca 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -172,7 +172,9 @@ libknots_la_SOURCES =				\
 	common/ref.h				\
 	common/ref.c				\
 	common/errors.h				\
-	common/errors.c
+	common/errors.c				\
+	common/WELL1024a.h				\
+	common/WELL1024a.c				
 
 libknotd_la_SOURCES =				\
 	knot/stat/gatherer.c				\
diff --git a/src/common/WELL1024a.c b/src/common/WELL1024a.c
new file mode 100644
index 0000000000000000000000000000000000000000..1ddf3251c1f16c9a176c91be08f0c043e30e0721
--- /dev/null
+++ b/src/common/WELL1024a.c
@@ -0,0 +1,48 @@
+/* ***************************************************************************** */
+/* Copyright:      Francois Panneton and Pierre L'Ecuyer, University of Montreal */
+/*                 Makoto Matsumoto, Hiroshima University                        */
+/* Notice:         This code can be used freely for personal, academic,          */
+/*                 or non-commercial purposes. For commercial purposes,          */
+/*                 please contact P. L'Ecuyer at: lecuyer@iro.UMontreal.ca       */
+/* ***************************************************************************** */
+
+#define W 32
+#define R 32
+#define M1 3
+#define M2 24
+#define M3 10
+
+#define MAT0POS(t,v) (v^(v>>t))
+#define MAT0NEG(t,v) (v^(v<<(-(t))))
+#define Identity(v) (v)
+
+#define V0            STATE[state_i                   ]
+#define VM1           STATE[(state_i+M1) & 0x0000001fU]
+#define VM2           STATE[(state_i+M2) & 0x0000001fU]
+#define VM3           STATE[(state_i+M3) & 0x0000001fU]
+#define VRm1          STATE[(state_i+31) & 0x0000001fU]
+#define newV0         STATE[(state_i+31) & 0x0000001fU]
+#define newV1         STATE[state_i                   ]
+
+#define FACT 2.32830643653869628906e-10
+
+static unsigned int state_i = 0;
+static unsigned int STATE[R];
+static unsigned int z0, z1, z2;
+
+void InitWELLRNG1024a (unsigned int *init){
+   int j;
+   state_i = 0;
+   for (j = 0; j < R; j++)
+     STATE[j] = init[j];
+}
+
+double WELLRNG1024a (void){
+  z0    = VRm1;
+  z1    = Identity(V0)       ^ MAT0POS (8, VM1);
+  z2    = MAT0NEG (-19, VM2) ^ MAT0NEG(-14,VM3);
+  newV1 = z1                 ^ z2; 
+  newV0 = MAT0NEG (-11,z0)   ^ MAT0NEG(-7,z1)    ^ MAT0NEG(-13,z2) ;
+  state_i = (state_i + 31) & 0x0000001fU;
+  return ((double) STATE[state_i]  * FACT);
+}
diff --git a/src/common/WELL1024a.h b/src/common/WELL1024a.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b426cc62a6714d5b7baed255d50b2a194023858
--- /dev/null
+++ b/src/common/WELL1024a.h
@@ -0,0 +1,11 @@
+/* ***************************************************************************** */
+/* Copyright:      Francois Panneton and Pierre L'Ecuyer, University of Montreal */
+/*                 Makoto Matsumoto, Hiroshima University                        */
+/* Notice:         This code can be used freely for personal, academic,          */
+/*                 or non-commercial purposes. For commercial purposes,          */
+/*                 please contact P. L'Ecuyer at: lecuyer@iro.UMontreal.ca       */
+/* ***************************************************************************** */
+
+void InitWELLRNG1024a (unsigned int *init);
+double WELLRNG1024a (void);
+