rickecon / StructEst_W17

MACS 40200: Structural Estimation
33 stars 45 forks source link

Coding generalized beta family PDF's in PS2 #6

Open rickecon opened 7 years ago

rickecon commented 7 years ago

I want you to code up your own PDF functions for the gamma (GA) distribution, generalized gamma (GG) distribution, and generalized beta 2 (GB2) distribution for Problem Set 2. But I want to give you some direction also.

rickecon commented 7 years ago

My first recommendation is to create the three pdf functions in a Python module. A module is just a Python file (e.g., filename.py) that contains function definitions. I recommend that you call your module distributions.py, as it will contain the function definitions for the three PDF functions you will use in your problem set. You can import these function definitions into your Python script that runs your analyses by including the following import command at the top of your script.

import distributions as dst

You can then use in your script any of the imported functions that you defined in your module by putting the dst. prefix on the function name. For example, if you defined a function named GA_pdf() for the gamma distribution, you could call that after importing it as shown above by using the command dst.GA_pdf().

rickecon commented 7 years ago

I also wanted to give you some direction as to where to find the special functions that are in the denominators of the gamma (GA), generalized gamma (GG), and generalized beta 2 (GB2) distributions. The GA and GG distributions both have a function in the denominator \Gamma(z) that is the gamma function. This is not to be confused with the gamma distribution. The scipy.special library has many special functions, including this gamma function. You can import the scipy.special functions by using the following command.

import scipy.special as spc

Then, in you definitions for the GA and GG PDF's, you can include the gamma function by writing the command spc.gamma(z). In the GB2 PDF, you can include the beta function by writing the command spc.beta(p, q).