Taweret.models namespace
Submodules
- class Taweret.models.coleman_models.coleman_model_1[source]
Bases:
BaseModel- evaluate(input_values: array, model_param: array, full_corr=False) array[source]
Predict the mean and error for given input values
- Parameters:
input_values (numpy 1darray) -- input parameter values
model_param (numpy 1darray) -- value of the model parameter
- log_likelihood_elementwise(x_exp, y_exp, y_err, model_param)[source]
Calculate log_likelihood for array of points given
Returns:
- log_likelisnp.ndarray
an array of length as shape[0] of the input evaluation points
Example:
class MyModel(BaseModel): def log_likelihood_elementwise( self, y_exp, y_err, model_params ): # Assuming a normal distribution for error y = self.evaluate(model_params) # If y_exp, y_err, y are numpy arrays of same length return np.exp(-(y - y_exp) **2 / (2 * y_err ** 2)) \ / np.sqrt(2 * np.pi * y_err ** 2))
- property prior
- class Taweret.models.coleman_models.coleman_model_2[source]
Bases:
BaseModel- evaluate(input_values: array, model_param: array, full_corr=False) array[source]
Predict the mean and error for given input values
- Parameters:
input_values (numpy 1darray) -- input parameter values
model_param (numpy 1darray) -- value of the model parameter
- log_likelihood_elementwise(x_exp, y_exp, y_err, model_param)[source]
Calculate log_likelihood for array of points given
Returns:
- log_likelisnp.ndarray
an array of length as shape[0] of the input evaluation points
Example:
class MyModel(BaseModel): def log_likelihood_elementwise( self, y_exp, y_err, model_params ): # Assuming a normal distribution for error y = self.evaluate(model_params) # If y_exp, y_err, y are numpy arrays of same length return np.exp(-(y - y_exp) **2 / (2 * y_err ** 2)) \ / np.sqrt(2 * np.pi * y_err ** 2))
- property prior
- class Taweret.models.coleman_models.coleman_truth[source]
Bases:
BaseModel- evaluate(input_values: array) array[source]
Predict the mean and error for given input values
- Parameters:
input_values (numpy 1darray) -- input parameter values
- log_likelihood_elementwise(x_exp, y_exp, y_err, model_param)[source]
Calculate log_likelihood for array of points given
Returns:
- log_likelisnp.ndarray
an array of length as shape[0] of the input evaluation points
Example:
class MyModel(BaseModel): def log_likelihood_elementwise( self, y_exp, y_err, model_params ): # Assuming a normal distribution for error y = self.evaluate(model_params) # If y_exp, y_err, y are numpy arrays of same length return np.exp(-(y - y_exp) **2 / (2 * y_err ** 2)) \ / np.sqrt(2 * np.pi * y_err ** 2))
- class Taweret.models.polynomial_models.cos_exp(k, x0)[source]
Bases:
BaseModelCosine Taylor series expansion model class.
Parameters:
- param int k:
the degree of the expansion.
- param float x0:
the center of the expansion.
- evaluate(x)[source]
Evaluate the Taylor series at a grid of x's. The standard deviation output is set to 1 by default.
Parameters:
- param np.ndarray x:
design matrix.
Returns:
- returns:
mean and standard deviation of the model at the x grid points.
- rtype:
np.ndarray, np.ndarray
- return values:
mean predictions.
- return values:
standard deviation of the predictions.
- class Taweret.models.polynomial_models.polynomal_model(a=0, b=0, c=1, p=1)[source]
Bases:
BaseModelPolynomial models class. Used to define a function of the form
\[f(x) = c(x-a)^p + b\]Parameters:
- param float a:
center parameter.
- param float b:
shift parameter.
- param float c:
scale parameter.
- param float p:
power parameter.
- evaluate(x)[source]
Evaluate the polynomial at a grid of x's. The standard deviation output is set to 1 by default.
Parameters:
- param np.ndarray x:
design matrix.
Returns:
- returns:
mean and standard deviation of the model at the x grid points.
- rtype:
np.ndarray, np.ndarray
- return values:
mean predictions.
- return values:
standard deviation of the predictions.
- class Taweret.models.polynomial_models.sin_cos_exp(ks, kc, xs, xc)[source]
Bases:
BaseModelTaylor series expansion of
\[f(x) = \sin(x_1) + \cos(x_2)\]Parameters:
- param int ks:
the degree of the sine expansion.
- param int kc:
the degree of the cosine expansion.
- param float xs:
the center of the sine expansion.
- param float xc:
the center of the cosine expansion.
- evaluate(x)[source]
Evaluate the model at a grid of x's. The standard deviation output is set to 1 by default.
Parameters:
- param np.ndarray x:
design matrix.
Returns:
- returns:
mean and standard deviation of the model at the x grid points.
- rtype:
np.ndarray, np.ndarray
- return values:
mean predictions.
- return values:
standard deviation of the predictions.
- class Taweret.models.polynomial_models.sin_exp(k, x0)[source]
Bases:
BaseModelSine Taylor series expansion model class.
Parameters:
- param int k:
the degree of the expansion.
- param float x0:
the center of the expansion.
- evaluate(x)[source]
Evaluate the Taylor Series at a grid of x's. The standard deviation output is set to 1 by default.
Parameters:
- param np.ndarray x:
design matrix.
Returns:
- returns:
mean and standard deviation of the model at the x grid points.
- rtype:
np.ndarray, np.ndarray
- return values:
mean predictions.
- return values:
standard deviation of the predictions.
- class Taweret.models.samba_models.Data[source]
Bases:
BaseModel- evaluate(input_values: array, error=0.01) array[source]
Evaluate the data and error for given input values
Parameters:
- input_valuesnumpy 1darray
coupling strength (g) values for data generation
- errorfloat
defines the relative error as a fraction between (0,1)
Returns:
- datanumpy 1darray
The array of data points
- sigmanumpy 1darray
The errors on each data point
- class Taweret.models.samba_models.Highorder(order, error_model='informative')[source]
Bases:
BaseModelThe SAMBA highorder series expansion function.
Parameters:
- orderint
Truncation order of expansion
- error_modelstr
Error calculation method. Either 'informative' or 'uninformative'
- raises TypeError:
If the order is not an integer
- evaluate(input_values: array) array[source]
Evaluate the mean and standard deviation for given input values
Parameters:
- input_valuesnumpy 1darray
coupling strength (g) values
Returns:
- meannumpy 1darray
The mean of the model
- np.sqrt(var)numpy 1darray
The truncation error of the model
- log_likelihood_elementwise(x_exp, y_exp, y_err, model_param)[source]
Calculate log_likelihood for array of points given
Returns:
- log_likelisnp.ndarray
an array of length as shape[0] of the input evaluation points
Example:
class MyModel(BaseModel): def log_likelihood_elementwise( self, y_exp, y_err, model_params ): # Assuming a normal distribution for error y = self.evaluate(model_params) # If y_exp, y_err, y are numpy arrays of same length return np.exp(-(y - y_exp) **2 / (2 * y_err ** 2)) \ / np.sqrt(2 * np.pi * y_err ** 2))
- class Taweret.models.samba_models.Loworder(order, error_model='informative')[source]
Bases:
BaseModelThe SAMBA loworder series expansion function. This model has been previously calibrated.
Parameters:
- orderint
Truncation order of expansion
- error_modelstr
Error calculation method. Either 'informative' or 'uninformative'
- raises TypeError:
If the order is not an integer
- evaluate(input_values: array) array[source]
Evaluate the mean and standard deviation for given input values to the function
Parameters:
- input_valuesnumpy 1darray
coupling strength (g) values
Returns:
- meannumpy 1darray
The mean of the model
- np.sqrt(var)numpy 1darray
The truncation error of the model
- log_likelihood_elementwise(x_exp, y_exp, y_err, model_param)[source]
Calculate log_likelihood for array of points given
Returns:
- log_likelisnp.ndarray
an array of length as shape[0] of the input evaluation points
Example:
class MyModel(BaseModel): def log_likelihood_elementwise( self, y_exp, y_err, model_params ): # Assuming a normal distribution for error y = self.evaluate(model_params) # If y_exp, y_err, y are numpy arrays of same length return np.exp(-(y - y_exp) **2 / (2 * y_err ** 2)) \ / np.sqrt(2 * np.pi * y_err ** 2))
- class Taweret.models.samba_models.TrueModel[source]
Bases:
BaseModel- evaluate(input_values: array) array[source]
Evaluate the mean of the true model for given input values.
Parameters:
- input_valuesnumpy 1darray
coupling strength (g) values
Returns:
- meannumpy 1darray
The true model evaluated at each point of the given input space
- np.sqrt(var)numpy 1darray
The standard deviation of the true model. This will obviously be an array of zeros.
- log_likelihood_elementwise(x_exp, y_exp, y_err)[source]
Calculate log_likelihood for array of points given
Returns:
- log_likelisnp.ndarray
an array of length as shape[0] of the input evaluation points
Example:
class MyModel(BaseModel): def log_likelihood_elementwise( self, y_exp, y_err, model_params ): # Assuming a normal distribution for error y = self.evaluate(model_params) # If y_exp, y_err, y are numpy arrays of same length return np.exp(-(y - y_exp) **2 / (2 * y_err ** 2)) \ / np.sqrt(2 * np.pi * y_err ** 2))