简体   繁体   English

使用MathNet在C#中给定指数的幂律分布

[英]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. 建议我使用MathNet.Iridium库来帮助我。 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? 是否有人在这方面有更多的经验,可以给我一些提示或建议吗?

To generate values of a distribution of your choice, you could use the inverse cumulative distribution function, as mentioned in the wikipedia . 要生成您选择的分布的值,可以使用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. Random在这里会很好。
  4. Input the value into your ICDF. 将值输入您的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. 如果您在第2步中遇到问题,也许https://mathoverflow.net/上的人员可以为您提供帮助。

Edit: If you just need any power law distribution with exponent gamma, this will generate one value: 编辑:如果您只需要指数gamma的任何幂律分布,则将生成一个值:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM