API#
- pccg.splines.bs(x, knots, boundary_knots, degree=3, intercept=False)[source]#
Generate the B-spline basis matrix for a polynomial spline.
This function mimick the function bs in R package splines
- Parameters:
x (Tensor) – Values at which basis functions are evaludated.
knots (Tensor) – Internal breakpoints that define the spline.
boundary_knots (Tensor) – Boundary points
degree (int, optional) – The degree of the piecewise polynomial. The default is 3 for cubic splines.
intercept (bool, optional) – If True, an intercept is included in the basis. Default is False.
- Returns:
- A tensor of dimension (len(x), df),
where df = len(knots) + degree if intercept = False, df = len(knots) + degree + 1 if intercept = True.
- Return type:
design_matrix (Tensor)
- pccg.splines.pbs(x, knots, boundary_knots=tensor([-3.1416, 3.1416]), degree=3, intercept=False)[source]#
Compute the design matrix of a periodic B-spline.
This function mimick the pbs function in R package pbs.
- Parameters:
x (Tensor) – Values at which basis functions are evaludated.
knots (Tensor) – Internal breakpoints that define the spline.
boundary_knots (Tensor) – Boundary points
degree (int, optional) – The degree of the piecewise polynomial. The default is 3 for cubic splines.
intercept (bool, optional) – If True, an intercept is included in the basis. Default is False.
- Returns:
- A tensor of dimension (len(x), df),
where df = len(knots) if intercept = False, df = len(knots) + 1 if intercept = True.
- Return type:
design_matrix (Tensor)
- pccg.splines.bs_lj(r, r_min, r_max, num_of_basis, omega=False)[source]#
Compute the design matrix of a custimized B-spline for Lennard-Jones type interaction.
- Parameters:
r (Tensor) – Distances at which basis functions are evaluated.
r_min (float) – A cutoff distance. When r < r_min, the interaction becomes repulsive and the basis function will provide a postive value.
r_max (float) – A cutoff distance. When r > r_max, all basis functions are zeros.
num_of_basis (int) – The number of basis.
omega (bool) –
Integral of secondary derivatives. If True, the function will also return a matrix omega. Omega[i,j] = int_{r_min}^{r_max}
basis_i.derivative(2)*basis_j.derivative(2) dr.
This matrix is useful when fitting a smoothing splines by addding a penaly term controling the secondary derivative of splines.
- Returns:
A matrix of dimension (len(r), num_of_basis). omega (Tensor): A matrix containing the integral of the splines’
second derivatives
- Return type:
design_matrix (Tensor)
- pccg.splines.bs_rmsd(r, r_max, num_of_basis)[source]#
Compute the design matrix of a custimized B-spline for a biasing potential on RMSD.
- Parameters:
r (Tensor) – Distances at which basis functions are evaluated.
r_max (float) – A cutoff distance. When r > r_max, all basis functions are zeros.
num_of_basis (int) – The number of basis.
- Returns:
A matrix of dimension (len(r), num_of_basis).
- Return type:
design_matrix (Tensor)
- pccg.CL.contrastive_learning(log_q_noise, log_q_data, basis_noise, basis_data, options={'disp': True, 'gtol': 1e-05})[source]#
Contrastive learning coefficients
- Parameters:
log_q_noise (1-dimensional tensor) – the logrithm of probability density for noise data under the noise distribution
log_q_data (1-dimensional tensor) – the logrithm of probability density for target data under the noise distribution
basis_noise (2-dimensional tensor) – the design matrix contraining basis values of noise data for compute the logrithm of probablity density for the target distribution
basis_data (2-dimensional tensor) – the design matrix contraining basis values of target data for compute the logrithm of probablity density for the target distribution
- Return type:
alpha