Question: Python coding Question: Please write a python code that solves this, thank you! Hint: Exercise 3.3. Random numbers with a power-law distribution. Implement a function

Python coding

Question:

Python coding Question: Please write a python code that solves this, thank

Please write a python code that solves this, thank you!

Hint:

you! Hint: Exercise 3.3. Random numbers with a power-law distribution. Implement a

function that, given the exponent >1, generates a sequence of positive random

Exercise 3.3. Random numbers with a power-law distribution. Implement a function that, given the exponent >1, generates a sequence of positive random integers ni>nmin distributed according to the probability p(n)x. [Hint: Follow the procedure described in the paragraph above: write p(n); calculate C(n); invert it to find the analytical dependence for C1(n), and use it to generate the sequence. You might execute this exercise with continuous numbers instead of integers, in which case you will obtain xi=xminri1a1.J Using C(n), we can easily (and efficiently) generate a series of random numbers ni that are distributed according to p(n). To do so, we need to take C1(n), i.e., the inverse of C(n), which is always well-defined because C(n) decreases monotonically from one to zero. By generating a uniformly distributed sequence of numbers ri in the interval [0,1], we can directly build the sequence ni by setting ni=C1(ri), which is distributed according to the probability function p(n) (when implementing this, you need to consider that C(n) is a discrete function and therefore ri should be a value of its image, which can easily be achieved by rounding). Power-law distributions have noisy tails and are data hungry. Instead of directly computing the probability distribution of fire sizes p(n) (which might be very noisy if k is small), we are going to calculate the complementary cumulative distribution function (cCDF) C(n), i.e., the probability of a fire size being larger than or equal to n. More explicitly, C(n) can be expressed as follows: C(n)=m=n+p(m) As p(n)>0 for all n (i.e., fires of all size are possible), C(n) is positively defined and monotonically decreasing, taking values from one to zero. If the probability function has a power-law distribution (i.e., p(n)n ), then C(n)n1forn Exercise 3.3. Random numbers with a power-law distribution. Implement a function that, given the exponent >1, generates a sequence of positive random integers ni>nmin distributed according to the probability p(n)x. [Hint: Follow the procedure described in the paragraph above: write p(n); calculate C(n); invert it to find the analytical dependence for C1(n), and use it to generate the sequence. You might execute this exercise with continuous numbers instead of integers, in which case you will obtain xi=xminri1a1.J Using C(n), we can easily (and efficiently) generate a series of random numbers ni that are distributed according to p(n). To do so, we need to take C1(n), i.e., the inverse of C(n), which is always well-defined because C(n) decreases monotonically from one to zero. By generating a uniformly distributed sequence of numbers ri in the interval [0,1], we can directly build the sequence ni by setting ni=C1(ri), which is distributed according to the probability function p(n) (when implementing this, you need to consider that C(n) is a discrete function and therefore ri should be a value of its image, which can easily be achieved by rounding). Power-law distributions have noisy tails and are data hungry. Instead of directly computing the probability distribution of fire sizes p(n) (which might be very noisy if k is small), we are going to calculate the complementary cumulative distribution function (cCDF) C(n), i.e., the probability of a fire size being larger than or equal to n. More explicitly, C(n) can be expressed as follows: C(n)=m=n+p(m) As p(n)>0 for all n (i.e., fires of all size are possible), C(n) is positively defined and monotonically decreasing, taking values from one to zero. If the probability function has a power-law distribution (i.e., p(n)n ), then C(n)n1forn

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!