diff --git a/Makefile b/Makefile
index 146c8c656c4aacc50debdbe7a16936ef810cc1cd..7756f83a1db34e27f3bf06278d902837b88d268a 100644
--- a/Makefile
+++ b/Makefile
@@ -2,11 +2,14 @@ CFLAGS = -g -O0 -Wall
 
 all: swiftmpistepsim swiftmpifakestepsim
 
-swiftmpistepsim: swiftmpistepsim.c mpiuse.c mpiuse.h atomic.h cycle.h clocks.h clocks.c
-	mpicc $(CFLAGS) -o swiftmpistepsim swiftmpistepsim.c mpiuse.c clocks.c -lpthread -lm
+SRC = mpiuse.c clocks.c histogram.c
+INC = mpiuse.h atomic.h cycle.h clocks.h histogram.h
 
-swiftmpifakestepsim: swiftmpifakestepsim.c mpiuse.c mpiuse.h atomic.h cycle.h clocks.h clocks.c
-	mpicc $(CFLAGS) -o swiftmpifakestepsim swiftmpifakestepsim.c mpiuse.c clocks.c -lpthread -lm
+swiftmpistepsim: swiftmpistepsim.c $(SRC) $(INC)
+	mpicc $(CFLAGS) -o swiftmpistepsim swiftmpistepsim.c $(SRC) -lpthread -lm
+
+swiftmpifakestepsim: swiftmpifakestepsim.c $(SRC) $(INC)
+	mpicc $(CFLAGS) -o swiftmpifakestepsim swiftmpifakestepsim.c $(SRC) -lpthread -lm
 
 clean:
 	rm -f swiftmpistepsim
diff --git a/histogram.h b/histogram.h
index 9e281696949ac05976d0d1437a327d5ee7d2d518..1ddd42544eb168b51590171df46c8648ed8b6a08 100644
--- a/histogram.h
+++ b/histogram.h
@@ -20,7 +20,7 @@
 #define SWIFT_HISTOGRAM_H
 
 /*  Bins in a histogram. Note this must be an even number. */
-#define NHIST 2048
+#define NHIST 65536
 
 /**  Histogram structure. */
 struct histogram {
diff --git a/mpiuse.c b/mpiuse.c
index 9d8d037dcce15d064cdccaf224c0b35161941900..e5d56aa4921d6f087cc433bd3cb21c6263b76a28 100644
--- a/mpiuse.c
+++ b/mpiuse.c
@@ -35,6 +35,7 @@
 #include "clocks.h"
 #include "cycle.h"
 #include "error.h"
+#include "histogram.h"
 
 /* Our rank. */
 extern int myrank;
@@ -293,14 +294,19 @@ static double gauss_rand_upper(void) {
  * @param uniform whether to use a uniform distribution other gaussian, unless
  *                cdf is defined, in which case this parameter is ignored.
  * @param cdf text file containing a normalized CDF to use as a basis for
- * inverse transform sampling of the randoms. NULL for no file.
+ *              inverse transform sampling of the randoms. NULL for no file.
+ * @param odata text file containing a values representing a occurences of the
+ *              expected distribution -- converted into a normalised CDF to
+ *              use as a basis for inverse transform sampling of the
+ *              randoms. NULL for no file. Not use if cdf is not NULL.
  */
 void mpiuse_log_generate(int nr_nodes, int nr_logs, int size, int random,
-                         long int seed, int uniform, const char *cdf) {
+                         long int seed, int uniform, const char *cdf,
+                         const char *odata) {
 
-  /* Only used for CDF, may need to increase these. */
+  /* Only used for CDFs, may need to increase these. */
   int nvals = 0;
-  double imin[1024], imax[1024], value[1024];
+  double imin[NHIST], imax[NHIST], value[NHIST];
 
   /* Note that each rank exchanges messages with all the others and each "log"
    * has the same size. */
@@ -325,6 +331,31 @@ void mpiuse_log_generate(int nr_nodes, int nr_logs, int size, int random,
       }
     }
     fclose(infile);
+  } else if (odata != NULL) {
+    double *values;
+    int nvalues;
+    if (histread(odata, &values, &nvalues)) {
+      printf("## Read %d occurence values from %s\n", nvalues, odata);
+      struct histogram *h = calloc(1, sizeof(struct histogram));
+      histmake(nvalues, values, h);
+      printf("## Created cumulative histogram with %d values:\n", h->nvalues);
+      printf("# value sum\n");
+      imin[0] = 0.0;
+      imax[0] = h->values[0];
+      value[0] = h->sums[0];
+      for (int k = 1; k < h->nvalues; k++) {
+        imin[k] = h->values[k-1] ;
+        imax[k] = h->values[k];
+        value[k] = h->sums[k];
+        printf("%f %24.17g\n", h->values[k], h->sums[k]);
+      }
+      nvals = h->nvalues;
+
+      free(h);
+      free(values);
+    } else {
+      error("Failed to read occurrence data from file: %s", odata);
+    }
   }
 
   /* Message tags increment with across rank logs. */
@@ -334,8 +365,8 @@ void mpiuse_log_generate(int nr_nodes, int nr_logs, int size, int random,
     /* Set size for this messages. */
     int logsize = size;
     if (random) {
-      if (cdf) {
-        /* CDF randoms. */
+      if (cdf || odata) {
+        /* CDF based randoms. */
         double rand = drand48();
 
         /* Binary search for containing bin for this rand. */
diff --git a/mpiuse.h b/mpiuse.h
index f621698be1f8cc8cf14a029e55654ce08dfcfacf..3545b7c5a6ee1eade998008063bba68bb8e2924b 100644
--- a/mpiuse.h
+++ b/mpiuse.h
@@ -102,6 +102,7 @@ int mpiuse_nr_ranks(void);
 void mpiuse_dump_logs(int nranks, const char *logfile);
 
 void mpiuse_log_generate(int nr_nodes, int nr_logs, int size, int random,
-                         long int seed, int uniform, const char *cdf);
+                         long int seed, int uniform, const char *cdf,
+                         const char *odata);
 
 #endif /* SWIFT_MPIUSE_H */
diff --git a/swiftmpifakestepsim.c b/swiftmpifakestepsim.c
index 9e80be89ff7b6d5e860ccb20658a27eb1b3262ea..5b8a2047f192ef26a71d3c8b570efebaa05f524c 100644
--- a/swiftmpifakestepsim.c
+++ b/swiftmpifakestepsim.c
@@ -346,7 +346,8 @@ static void usage(char *argv[]) {
           " options: -v verbose, -d data check, -s size (bytes/scale), \n"
           "\t[-r uniform random from 1 to size, | \n"
           "\t-r -g half gaussian random from 1 with 2.5 sigma size., | \n"
-          "\t-r -c <file> use cdf from file, size is a scale factor.,] \n"
+          "\t-r -c <file> use cdf from file, size is a scale factor., |\n"
+          "\t-r -o <file> use occurence sample of values in a file, size is a scale factor.,] \n"
           "\t-x random seed\n");
   fflush(stderr);
 }
@@ -377,9 +378,10 @@ int main(int argc, char *argv[]) {
   int random = 0;
   int uniform = 1;
   char *cdf = NULL;
+  char *odata = NULL;
   int opt;
   unsigned int seed = default_seed;
-  while ((opt = getopt(argc, argv, "vds:rgx:c:")) != -1) {
+  while ((opt = getopt(argc, argv, "vds:rgx:c:o:")) != -1) {
     switch (opt) {
       case 'd':
         datacheck = 1;
@@ -396,6 +398,9 @@ int main(int argc, char *argv[]) {
       case 'r':
         random = 1;
         break;
+      case 'o':
+        odata = optarg;
+        break;
       case 'v':
         verbose = 1;
         break;
@@ -411,7 +416,8 @@ int main(int argc, char *argv[]) {
     if (myrank == 0) usage(argv);
     return 1;
   }
-
+  if (cdf != NULL && odata != NULL) error("Cannot use -c and -o options together");
+  
   int nr_logs = atoi(argv[optind]);
   if (nr_logs == 0)
     error("Expected number of messages to exchange, got: %s", argv[optind]);
@@ -425,6 +431,11 @@ int main(int argc, char *argv[]) {
             "Generating %d fake logs for %d ranks with randoms"
             " based on cdf %s scaled by factor %d",
             nr_logs, nr_nodes, cdf, size);
+      } else if (odata != NULL) {
+        message(
+            "Generating %d fake logs for %d ranks with randoms"
+            " based on occurence data %s scaled by factor %d",
+            nr_logs, nr_nodes, cdf, size);
 
       } else if (uniform) {
         message(
@@ -442,7 +453,7 @@ int main(int argc, char *argv[]) {
               nr_nodes, size);
     }
   }
-  mpiuse_log_generate(nr_nodes, nr_logs, size, random, seed, uniform, cdf);
+  mpiuse_log_generate(nr_nodes, nr_logs, size, random, seed, uniform, cdf, odata);
   int nranks = mpiuse_nr_ranks();
 
   /* Create communicators for each MPI rank. */