ThreeB 1.1
Public Member Functions | Private Attributes
SampledMultispot::GibbsSampler Class Reference

Draw samples from the spot states given the spots positions and some data. More...

#include <sampled_multispot.h>

List of all members.

Public Member Functions

 GibbsSampler (const vector< vector< double > > &pixel_intensities_, const vector< vector< double > > &spot_intensities_, const vector< Vector< 4 > > &spots_, const Matrix< 3 > A_, const Vector< 3 > pi_, double variance_, int sample_iterations_)
void set_variance (double v)
void reset ()
template<class T >
void next (T &rng)
const vector< vector< State > > & sample () const
const vector< vector< double > > & sample_intensities () const

Private Attributes

const vector< vector< double > > & pixel_intensities
const vector< vector< double > > & spot_intensities
const vector< Vector< 4 > > spots
const Matrix< 3 > A
const Vector< 3 > pi
const double base_variance
double variance
const int sample_iterations
const int num_frames
const int num_pixels
const vector< int > O
vector< vector< State > > current_sample
vector< vector< double > > current_sample_intensities

Detailed Description

Draw samples from the spot states given the spots positions and some data.

Variable naming matches that in FitSpots.

Definition at line 188 of file sampled_multispot.h.


Constructor & Destructor Documentation

SampledMultispot::GibbsSampler::GibbsSampler ( const vector< vector< double > > &  pixel_intensities_,
const vector< vector< double > > &  spot_intensities_,
const vector< Vector< 4 > > &  spots_,
const Matrix< 3 >  A_,
const Vector< 3 >  pi_,
double  variance_,
int  sample_iterations_ 
) [inline]

Definition at line 207 of file sampled_multispot.h.

References assert_same_size(), and spot_intensities.

    :pixel_intensities(pixel_intensities_), //pixel_intensities: [frame][pixels]
     spot_intensities(spot_intensities_),   //spot_intensities: [spot][pixel]
     spots(spots_),
     A(A_),
     pi(pi_),
     base_variance(variance_),
     variance(variance_),
     sample_iterations(sample_iterations_),
     num_frames(pixel_intensities.size()),
     num_pixels(pixel_intensities[0].size()),
        //Observations vector. As usual for this application, the observations are just
        //numbered integers which refer to data held elsewhere.
     O(sequence(num_frames)),
        //Start all spots OFF, so the intensity is 0. OFF is 1 or 2, not 0!!!
        //sample_list: [sample][spot][frame]: list of samples drawn using Gibbs sampling
     current_sample(spots.size(), vector<State>(num_frames, 2)), //current sample [spot][frame]
        //pixel intensities assosciated with the current sample [frame][pixel]
     current_sample_intensities(num_frames, vector<double>(num_pixels))
    {
        //Check a bunch of stuff
        assert_same_size(pixel_intensities);
        assert_same_size(spot_intensities);

    }

Member Function Documentation

void SampledMultispot::GibbsSampler::set_variance ( double  v) [inline]

Update the noide variance.

Used for adding thermal noise.

Parameters:
vnoise variance.

Definition at line 241 of file sampled_multispot.h.

Referenced by NegativeFreeEnergy::operator()().

    {
        variance = v;
    }
void SampledMultispot::GibbsSampler::reset ( ) [inline]

Reset the gibbs sampler oro the initial state (all spots off)

Definition at line 248 of file sampled_multispot.h.

    {
        vector<State> off(num_frames, 2);
        fill(current_sample.begin(), current_sample.end(), off);

        vector<double> black(num_pixels);
        fill(current_sample_intensities.begin(), current_sample_intensities.end(), black);
        variance = base_variance;
    }
template<class T >
void SampledMultispot::GibbsSampler::next ( T &  rng) [inline]

Get the next sample.

Parameters:
rngRandom number generator

Definition at line 260 of file sampled_multispot.h.

References SampledMultispot::add_spot(), forward_algorithm_delta(), SampledMultispot::remove_spot(), and spot_intensities.

Referenced by FreeEnergyHessian::hessian(), NegativeFreeEnergy::operator()(), and FitSpots::try_modifying_model().

    {
        for(int j=0; j < sample_iterations; j++)
            for(int k=0; k < (int) spots.size(); k++)
            {
                //Subtract off the spot we're interested in.
                remove_spot(current_sample_intensities, spot_intensities[k], current_sample[k]);

                //Now current_sample_intensities is the image value for every spot in every frame,
                //except the current spot, which is always set to off. This allows us to add it in 
                //easily.
                SpotWithBackground B(current_sample_intensities, spot_intensities[k], pixel_intensities, variance);
                vector<array<double, 3> > delta = forward_algorithm_delta(A, pi, B, O);
                current_sample[k] = backward_sampling<3,State, T>(A, delta, rng);

                //Put the newly sampled spot in
                add_spot(current_sample_intensities, spot_intensities[k], current_sample[k]);
            }
    }
const vector<vector<State> >& SampledMultispot::GibbsSampler::sample ( ) const [inline]

Retrieve the current sample.

Definition at line 286 of file sampled_multispot.h.

Referenced by FreeEnergyHessian::hessian(), and FitSpots::try_modifying_model().

    {
        return current_sample;
    }
const vector<vector<double> >& SampledMultispot::GibbsSampler::sample_intensities ( ) const [inline]

Retrieve the intensities for the current sample.

Definition at line 291 of file sampled_multispot.h.

Referenced by FreeEnergyHessian::hessian(), NegativeFreeEnergy::operator()(), and FitSpots::try_modifying_model().


Member Data Documentation

const vector<vector<double> >& SampledMultispot::GibbsSampler::pixel_intensities [private]

Definition at line 190 of file sampled_multispot.h.

const vector<vector<double> >& SampledMultispot::GibbsSampler::spot_intensities [private]

Definition at line 191 of file sampled_multispot.h.

const vector<Vector<4> > SampledMultispot::GibbsSampler::spots [private]

Definition at line 192 of file sampled_multispot.h.

const Matrix<3> SampledMultispot::GibbsSampler::A [private]

Definition at line 193 of file sampled_multispot.h.

const Vector<3> SampledMultispot::GibbsSampler::pi [private]

Definition at line 194 of file sampled_multispot.h.

Definition at line 195 of file sampled_multispot.h.

Definition at line 196 of file sampled_multispot.h.

Definition at line 198 of file sampled_multispot.h.

Definition at line 199 of file sampled_multispot.h.

Definition at line 199 of file sampled_multispot.h.

const vector<int> SampledMultispot::GibbsSampler::O [private]

Definition at line 200 of file sampled_multispot.h.

Definition at line 202 of file sampled_multispot.h.

Definition at line 203 of file sampled_multispot.h.


The documentation for this class was generated from the following file: