# Priors

Redback uses `bilby`

under the hood for priors. See here for general documentation of priors in `bilby`

.

## Analytical priors

Thanks to `bilby`

there are several different priors already implemented.

Beta

Categorical

Cauchy

ChiSquared

Cosine

DeltaFunction

Exponential

FermiDirac

Gamma

Gaussian

HalfGaussian

LogGaussian

LogUniform

Logistic

Lorentzian

PowerLaw

Sine

StudentT

SymmetricLogUniform

TruncatedGaussian

Uniform

## Interpolated or from file

Users can also create a prior from a grid of values i.e., an interpolated_prior. See documentation here.

## Constrained priors

Sometimes there are some additional constraints on the priors that are difficult to parameterise or not on a sampled parameter.

For example, the rotational energy of a neutron star cannot be exceeded in a super luminous supernova. Or that a numerical surrogate is only valid in a certain domain etc. In redback, we have written several of these constraints which can be used by simply loading the particular constraint from redback.constraints and passing them to the bilby prior dictionary.

For example,

```
import redback
from bilby.core.prior import PriorDict, Uniform, Constraint
priors = PriorDict(conversion_function=redback.constraints.slsn_constraint)
priors['erot_constraint'] = Constraint(minimum=0, maximum=100)
priors['t_nebula_min'] = Constraint(minimum=0, maximum=100)
```

Then define our priors on all other parameters in the normal way. You can then check whether the constraints are set up correctly by sampling from the prior via

```
priors.sample(1000)
```

You can implement your own constraints by following the constraint templates and `bilby`

documentation.
We note that the default priors do not have constraints active so analysis with constraints must construct the prior dictionary as above.
This new prior dictionary can be updated to include the default prior via

```
model = 'slsn'
priors.update(redback.priors.get_priors(model=model))
```

## Adding sigma to the prior

One can also add a sigma to the prior by using the `sigma`

keyword in the prior dictionary.
For the default `redback`

likelihood, this will overwrite the sigma in the data and estimate a constant sigma.
For other likelihoods, this may be added in quadrature to the y_err from the data.
Or be a systematic offset proportional to the model that is added in quadrature to the measured noise.
Please look at the likelihood documentation for more details.