artemis.generators.simutable.providers.glm¶
General linear model Simulate linear dependence between a predictor and set of independent random variables
Package Contents¶
-
class
artemis.generators.simutable.providers.glm.Provider¶ Bases:
faker.providers.BaseProviderSimple General Linear Model with noise
-
sample(self, X, beta, sigma)¶ Sample from a normal distribution with width defined as sigma mean defined as a GLM y(X) = beta.X otherwise, one can simply use the transformation y(X) = beta.X + sigma i.e. the mean of the predictor is a linear combination of independent variables, where the predictor follows a normal distribution, i.e. link function is normal. This can be extended to logistic function, for example, where the predictor is either 0 or 1 with a logit link function.
How to get the maximum of a faker? Need to scan the phase space? I need to get ymin and ymax to sample from y, X.
For now, just implement as y(X), ok this is equivalent as below. Xmin = min(X) Xmax = max(X) mu = np.dot(X,beta) ymin = np.dot(Xmin,beta) ymax = np.dot(Xmax,beta) pdfmax = stats.norm.pdf(mu, mu, sigma)
y = np.random.uniform(ymin,ymax) throw = np.random.uniform(0,pdfmax) if(throw < y): accept Should the scale go as 1/sqrt(sample size)?
-
glm(self, params_or_msg)¶ expect a dictionary
-