Power Law distribution for a given exponent in C# using MathNet

I am currently working on a project where I need to generate multiple values (floats or doubles preferably) that follow a power law distribution with a given exponent!

I was advised to use the MathNet.Iridium library to help me. The problem I have is that the documentation is not as explicit as it should be if there is any!

I see multiple distributions that fit the general idea of the power law distribution but I cannot pinpoint a good distribution to use with a certain exponent as a parameter.

Does anybody have more experience in that matter and could give me some hints or advice?

Answers


To generate values of a distribution of your choice, you could use the inverse cumulative distribution function, as mentioned in the wikipedia.

Step by step, this would look like:

  1. Choose a distribution function that you like.
  2. Calculate the inverse cumulative distribution function using pen and paper.
  3. Generate a value based on a uniform distribution on the unit interval. Random will do nicely here.
  4. Input the value into your ICDF.

The result is a value chosen at random using your chosen distribution function.

If you run into problems with step 2, maybe the folks at https://mathoverflow.net/ can help you.

Edit: If you just need any power law distribution with exponent gamma, this will generate one value:

double r = 1.0 / Math.Pow(1-new Random().NextDouble(), 1.0/(gamma+1));

Need Your Help

Kendo model binding causes not to show placeholder

html asp.net-mvc razor kendo-ui

For example a NumericTextBoxFor like bellow, does not show a placeholder. Instead, it shows a default value, in this case 0.

Spark cluster can't assign resources from remote scala application

scala hadoop apache-spark

So, I've been trying to get off of the ground running Spark-scala. I've written a simple test program, which just extends the SparkPi example a bit :