开发者

Java: Power Law Distribution [closed]

Clo开发者_开发问答sed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 4 years ago.

Improve this question

I'm trying to generate p2p network according to power law distribution. How to generate power law distribution in java? does it have any library?

thanks :)


If you can't/don't want to use a library:

In this case, the easiest way to go is to work out the CDF (check it against Wikipedia), that is the function F : x -> P(X < x). Then you draw uniform random numbers y on [0,1] with your favorite generator, and you solve y = F(x). The sequence of such x are identically distributed and follow a Power Law Distribution.

Edit: the answer is there


Maybe the Colt java library can help. It generates random numbers according to many distributions.


Apache Commons Math lib was quite slow on my system (maybe I missed something...). This standalone class PowerLaw.java worked for me.


This library: https://github.com/pbloem/powerlaws contains a power law generator, used as follows:

List<Double> data = new Continuous(3.14, 2.5).generate(1000);

This generates 1000 points from a power law distribution with 3.14 as minimal value and 2.5 as exponent. It also has a discrete distribution and a Continuous approximation of a discrete distribution. All these distribution can also be fit to existing data.

(Disclaimer: I wrote this library).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜