What is the meaning of "loc" and "scale" for the distributions in scipy.stats? I need to know the meaning of the variables loc and scale of the distributions in scipy.stats because I need to fit some data to several probability distribution functions for doing goodness of fit tests in order to decide which one fits better.
Specifically, it is necessary to use them always?
 A: Background
The SciPy distribution objects are, by default, the standardized version of a distribution. In practice, this means that some "special" location occurs at $x=0$, while something related to the scale/extent of the distribution occupies one unit. For example, the standard normal distribution has a mean of 0 and a standard deviation of 1.
The loc and scale parameters let you adjust the location and scale of a distribution. For example, to model IQ data, you'd build iq = scipy.stats.norm(loc=100, scale=15) because IQs are constructed so as to have a mean of 100 and a standard deviation of 15.
Why don't we just call them mean and sd? It helps to have a more generalized concept because not every distribution has a mean (e.g., the Cauchy distribution). Moreover, it's not always the location of the peak. The standard beta distribution is only defined between 0 and 1. For other versions of it, loc sets the minimum value and scale sets the valid range. For distribution with a beta-like shape extending from -1 to +1, you'd use scipy.stats.beta(a, b, loc=-1, scale=2).
All of these transformations take the same form:
dist.pdf(x, loc, scale) = standard_dist.pdf((x - loc)/scale) / scale It would be a good exercise to plot (say) the standard distribution, loc=±1, and scale=1, 2, 10 for a few different distributions. You'll get an intuitive sense for how these values affect the same sort of change.
Fitting Data
Whether you should fix or fit the loc and scale values depends on the nature of your problem and the target distribution. For a normal/Gaussian distribution, they're the quantities of interest; indeed, they completely describe the distribution. As a result, I'd fit them.
For other distributions, loc/scale control the support of the distribution (i.e., the range of possible values). You may already know this from some fact about the data-generating process. For example, if you're modeling scores between -10-10 with a beta distribution, I would just fix them accordingly (though SciPy can also fit it for you).
