Particles
- class ssapy.particles.Particles(particles, rvprobability, lnpriors=None, ln_weights=None)[source][source]
Bases:
object
A class for importance (re-)sampling orbit model parameter samples
- Parameters:
particles ((num_particles, 6) array_like) – Positions and velocities of orbiting object at epoch in meters and meters / second. The ‘chain’ part of the output from rvsampler.XXSampler.sample
rvprobability (class instance) – An instance of an RVProbability for this epoch. The Particles class wraps the lnlike method of the supplied RVProbability object.
ln_weights ((num_particles,) array_like, optional) – Weights for each particle in the input particles
- particles[source]
Positions and velocities of orbiting object at epoch in meters and meters / second. The ‘chain’ part of the output from RVSampler.sample
- Type:
(num_particles, ) array_like
- rvprobability[source]
An instance of an RVProbability for this epoch. The Particles class wraps the lnlike method of the supplied RVProbability object.
- Type:
class instance
- initial_particles[source]
Copy of input particles to enable reset_to_pseudo_prior()
- Type:
(num_particles, 6) array_like
- initial_ln_wts[source]
Copy of input log weights to enable reset_to_pseudo_prior()
- Type:
(num_particles,) array_like
- epoch[source]
The time at which the model parameters (position and velocity) are specified. If float, then should correspond to GPS seconds; i.e., seconds since 1980-01-06 00:00:00 UTC.
- Type:
float or astropy.time.Time
- lnpriors[source]
Log prior probabilities for each particle. The priors are as set in the input RVProbability object.
- Type:
(num_particles,) array_like
- reset_to_pseudo_prior()[source][source]
Reset the particles and weights to their values at instantiation
- lnlike(epoch_particles)[source][source]
Evaluate the log-likelihood of the input particles given internally stored measurements
- resample(num_particles)[source][source]
Resample particles to achieve near-uniform weighting per particle
- fuse(epoch_particles, verbose)[source][source]
Fuse particles from a different epoch and fuse internal particles and weights
Attributes Summary
Get the epoch time at which the particles (i.e., position and velocity) are defined
Get an array of log prior probabilities for each particle
Get a list of orbits corresponding to each stored particle
Methods Summary
Draw a single orbit model from the internal particle collection with probability proportional to the internal weights.
fuse
(epoch_particles[, verbose])Add particles from a new epoch and fuse all epoch particles and weights accordingly
lnlike
(orbits)Evaluate this epoch likelihood given one or more particles
mean
()Evaluate the weighted mean of all particles
move
(epoch)Move particles to the given epoch
resample
(num_particles)Resample particles to achieve near-uniform weighting per particle
reweight
(epoch_particles)Reweight particles using cross-epoch likelihoods
Attributes Documentation
Methods Documentation
- draw_orbit()[source][source]
Draw a single orbit model from the internal particle collection with probability proportional to the internal weights.
- Returns:
particle – Position and velocity for one particle
- Return type:
array (1, 6)
- fuse(epoch_particles, verbose=False)[source][source]
Add particles from a new epoch and fuse all epoch particles and weights accordingly
- lnlike(orbits)[source][source]
Evaluate this epoch likelihood given one or more particles
- Parameters:
orbits (List of Orbit class instances) – A list of the Orbit models for each particle, e.g., as generated by Particles.orbits
- Returns:
lnlike – Array of log-likelihood values for each particle
- Return type:
array (num_particles, )
- mean()[source][source]
Evaluate the weighted mean of all particles
- Returns:
mean – Weighted mean of the particle values (3*m, 3*m/s)
- Return type:
(6,) array_like
- move(epoch)[source][source]
Move particles to the given epoch
- Parameters:
epoch (astropy.time.Time) –
- Returns:
particles – Position and velocity for each particle at the new epoch
- Return type:
array (num_particles, 6)
- resample(num_particles)[source][source]
Resample particles to achieve near-uniform weighting per particle
- Parameters:
num_particles (int) – The number of particles to keep
- Return type:
None. Side effect is to update the internal particles state.
- reweight(epoch_particles)[source][source]
Reweight particles using cross-epoch likelihoods
- The weights for the kth particle are,
- w_k = log(Prod_i L_(d_i | theta_k) / L(d_j | theta_k))
= Sum_{i /= j} log(L(d_i | theta_k))
where j is the current epoch, theta are the particle parameters, and d_i is the data from epoch i.