\hypertarget{group__gStorm}{
\subsection{Storm classes}
\label{group__gStorm}\index{Storm classes@{Storm classes}}
}
\subsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structConjugateGradientOnly}{ConjugateGradientOnly$<$ Size, Precision $>$}
\begin{DoxyCompactList}\small\item\em Class for performing optimization with Conjugate Gradient, where only the derivatives are available. \end{DoxyCompactList}\item 
class \hyperlink{classNullGraphics}{NullGraphics}
\begin{DoxyCompactList}\small\item\em Graphics class which does absoloutely nothing. \end{DoxyCompactList}\item 
class \hyperlink{classDataForMCMC}{DataForMCMC}
\begin{DoxyCompactList}\small\item\em Closure hoding the data required do use GibbsSampler2 See \hyperlink{classFitSpots}{FitSpots} for naming of variables. \end{DoxyCompactList}\item 
struct \hyperlink{structSampledBackgroundData}{SampledBackgroundData}
\begin{DoxyCompactList}\small\item\em Closure holding image data generated using samples drawn from the model. \end{DoxyCompactList}\item 
struct \hyperlink{structSpotNegProbabilityDiffWithSampledBackground}{SpotNegProbabilityDiffWithSampledBackground}
\begin{DoxyCompactList}\small\item\em Compute the derivative of the negative log probability with respect to the parameters of one spot, given some samples of the other spots. \end{DoxyCompactList}\item 
class \hyperlink{classFreeEnergyHessian}{FreeEnergyHessian}
\begin{DoxyCompactList}\small\item\em Class for computing the Hessian of the negative free energy. \end{DoxyCompactList}\item 
class \hyperlink{classFitSpots}{FitSpots}
\begin{DoxyCompactList}\small\item\em Mega class which actually does the meat of the spot fitting. \end{DoxyCompactList}\item 
class \hyperlink{classFitSpotsGraphics}{FitSpotsGraphics}
\begin{DoxyCompactList}\small\item\em Graphics class for FittingSpots. \end{DoxyCompactList}\item 
class \hyperlink{classUserInterfaceCallback}{UserInterfaceCallback}
\begin{DoxyCompactList}\small\item\em Callback class used by \hyperlink{classFitSpots}{FitSpots} to provide enough hooks for a user interface. \end{DoxyCompactList}\item 
class \hyperlink{classSampledMultispot_1_1GibbsSampler}{SampledMultispot::GibbsSampler}
\begin{DoxyCompactList}\small\item\em Draw samples from the spot states given the spots positions and some data. \end{DoxyCompactList}\item 
class \hyperlink{classSampledMultispot_1_1GibbsSampler2}{SampledMultispot::GibbsSampler2}
\begin{DoxyCompactList}\small\item\em Gibbs sampling class which masks spots to reduce computation. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
auto\_\-ptr$<$ \hyperlink{classUserInterfaceCallback}{UserInterfaceCallback} $>$ \hyperlink{group__gStorm_ga9eb1610b36e31a838db0cd31cff2aa5b}{null\_\-ui} ()
\item 
auto\_\-ptr$<$ \hyperlink{classFitSpotsGraphics}{FitSpotsGraphics} $>$ \hyperlink{group__gStorm_ga05044c755e93ef9d37f91e0c708c0e27}{null\_\-graphics} ()
\item 
void \hyperlink{group__gStorm_gad0dc776b1dfaed9f8ad4d83ae6b33e56}{get\_\-spot\_\-pixels} (const vector$<$ ImageRef $>$ \&pixels, const Vector$<$ 4 $>$ \&spot, vector$<$ int $>$ \&out)
\item 
\hyperlink{structStateParameters}{StateParameters} \hyperlink{group__gStorm_ga36fa3bc23f458450a42e409d9e4f1c4f}{parse\_\-log\_\-file} (istream \&in)
\item 
double \hyperlink{group__gStorm_ga4aa9ab83b786fd72995cfa21c3f0861d}{brightness\_\-motion\_\-limit} (double mu, double sigma, bool not\_\-one)
\item 
void \hyperlink{group__gStorm_ga55c141b3f0c10f7046c69497ec29c50d}{fit\_\-spots\_\-new} (const vector$<$ Image$<$ float $>$ $>$ \&ims, \hyperlink{structStateParameters}{StateParameters} \&p, ofstream \&save\_\-spots, \hyperlink{classFitSpotsGraphics}{FitSpotsGraphics} \&gr)
\item 
void \hyperlink{group__gStorm_gaf79c717a2e7addbc7455dd79ea958eb5}{fit\_\-spots\_\-new} (const vector$<$ Image$<$ float $>$ $>$ \&ims, \hyperlink{structStateParameters}{StateParameters} \&p, ofstream \&save\_\-spots, \hyperlink{classFitSpotsGraphics}{FitSpotsGraphics} \&gr, \hyperlink{classUserInterfaceCallback}{UserInterfaceCallback} \&ui)
\item 
{\footnotesize template$<$class B $>$ }\\double \hyperlink{group__gStorm_ga0b300e882aad6e3c180df8f58bd5bf63}{spot\_\-shape\_\-s} (const TooN::Vector$<$ 2 $>$ \&x, const TooN::Vector$<$ 4, double, B $>$ \&phi)
\item 
{\footnotesize template$<$class B $>$ }\\std::pair$<$ double, TooN::Vector$<$ 4 $>$ $>$ \hyperlink{group__gStorm_ga6b2081a450ccc5950ae17115bf7a0c56}{spot\_\-shape\_\-diff\_\-position} (const TooN::Vector$<$ 2 $>$ \&x, const TooN::Vector$<$ 4, double, B $>$ \&phi)
\item 
{\footnotesize template$<$class B $>$ }\\std::tr1::tuple$<$ double, TooN::Vector$<$ 4 $>$, TooN::Matrix$<$ 4 $>$ $>$ \hyperlink{group__gStorm_gaf4680f7b58ed5c458939e464c4ead582}{spot\_\-shape\_\-hess\_\-position} (const TooN::Vector$<$ 2 $>$ \&x, const TooN::Vector$<$ 4, double, B $>$ \&phi)
\item 
{\footnotesize template$<$class B $>$ }\\std::tr1::tuple$<$ double, TooN::Vector$<$ 2 $>$, TooN::Matrix$<$ 2 $>$ $>$ \hyperlink{group__gStorm_ga110d3db1cf9bdb79a56498e6506c7c19}{spot\_\-shape\_\-hess} (const TooN::Vector$<$ 2 $>$ \&x, const TooN::Vector$<$ 4, double, B $>$ \&phi)
\item 
{\footnotesize template$<$class B $>$ }\\std::pair$<$ double, TooN::Vector$<$ 2 $>$ $>$ \hyperlink{group__gStorm_gafbd0826fe088e857f2e97105efa8ef6e}{spot\_\-shape\_\-diff} (const TooN::Vector$<$ 2 $>$ \&x, const TooN::Vector$<$ 4, double, B $>$ \&phi)
\item 
{\footnotesize template$<$class B $>$ }\\double \hyperlink{group__gStorm_ga4414bdd28d7ba4d708f3b329d7a2abad}{spot\_\-shape} (const TooN::Vector$<$ 2 $>$ \&x, const TooN::Vector$<$ 4, double, B $>$ \&phi)
\item 
{\footnotesize template$<$class Base $>$ }\\std::tr1::tuple$<$ double, TooN::Vector$<$ 2 $>$, TooN::Matrix$<$ 2 $>$ $>$ \hyperlink{group__gStorm_ga5d0cd4c20daf3c1eb6bfa65d655d0243}{log\_\-probability\_\-spot\_\-hess} (const CVD::SubImage$<$ float $>$ \&im, double variance, const TooN::Vector$<$ 4, double, Base $>$ \&spot\_\-parameters)
\item 
{\footnotesize template$<$class Base $>$ }\\std::pair$<$ double, TooN::Vector$<$ 2 $>$ $>$ \hyperlink{group__gStorm_gabab1ab1b780d7da267c5dccaef0b87c9}{log\_\-probability\_\-spot\_\-diff} (const CVD::SubImage$<$ float $>$ \&im, double variance, const TooN::Vector$<$ 4, double, Base $>$ \&spot\_\-parameters)
\item 
{\footnotesize template$<$class Base $>$ }\\double \hyperlink{group__gStorm_ga1a24bd3f98cfef3265ec27f522b790eb}{log\_\-probability\_\-spot} (const CVD::SubImage$<$ float $>$ \&im, double variance, const TooN::Vector$<$ 4, double, Base $>$ \&spot\_\-parameters)
\item 
double \hyperlink{group__gStorm_gac9fd2f658c90bcf942fde135dab63557}{log\_\-normal\_\-std} (double mu, double sigma)
\item 
double \hyperlink{group__gStorm_ga69425e80deea70f9bd15cc82b50768a3}{log\_\-normal\_\-mode} (double mu, double sigma)
\item 
double \hyperlink{group__gStorm_ga110afd744fdb0f40c6420b640f05a61c}{log\_\-log\_\-normal} (double x, double mu, double sigma)
\item 
double \hyperlink{group__gStorm_ga3a78c1d136f9878f2a14cd03ffcd6ba7}{diff\_\-log\_\-log\_\-normal} (double x, double mu, double sigma)
\item 
double \hyperlink{group__gStorm_ga132079a5bc2e1971da76daed8c010d2a}{hess\_\-log\_\-log\_\-normal} (double x, double mu, double sigma)
\end{DoxyCompactItemize}


\subsubsection{Function Documentation}
\hypertarget{group__gStorm_ga9eb1610b36e31a838db0cd31cff2aa5b}{
\index{Storm classes@{Storm classes}!null\_\-ui@{null\_\-ui}}
\index{null\_\-ui@{null\_\-ui}!Storm classes@{Storm classes}}
\paragraph[{null\_\-ui}]{\setlength{\rightskip}{0pt plus 5cm}auto\_\-ptr$<${\bf UserInterfaceCallback}$>$ null\_\-ui (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga9eb1610b36e31a838db0cd31cff2aa5b}


Factory function to generate an instance of \hyperlink{classNullGraphics}{NullGraphics}. 



Definition at line 81 of file multispot5.cc.



Referenced by fit\_\-spots\_\-new().


\begin{DoxyCode}
{
    return auto_ptr<UserInterfaceCallback>(new NullUICallback);
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga05044c755e93ef9d37f91e0c708c0e27}{
\index{Storm classes@{Storm classes}!null\_\-graphics@{null\_\-graphics}}
\index{null\_\-graphics@{null\_\-graphics}!Storm classes@{Storm classes}}
\paragraph[{null\_\-graphics}]{\setlength{\rightskip}{0pt plus 5cm}auto\_\-ptr$<${\bf FitSpotsGraphics}$>$ null\_\-graphics (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga05044c755e93ef9d37f91e0c708c0e27}


Factory function to generate an instance of \hyperlink{classNullGraphics}{NullGraphics}. 



Definition at line 108 of file multispot5.cc.



Referenced by Java\_\-ThreeBRunner\_\-call(), and mmain().


\begin{DoxyCode}
{
    return auto_ptr<FitSpotsGraphics>(new NullGraphics);
}
\end{DoxyCode}
\hypertarget{group__gStorm_gad0dc776b1dfaed9f8ad4d83ae6b33e56}{
\index{Storm classes@{Storm classes}!get\_\-spot\_\-pixels@{get\_\-spot\_\-pixels}}
\index{get\_\-spot\_\-pixels@{get\_\-spot\_\-pixels}!Storm classes@{Storm classes}}
\paragraph[{get\_\-spot\_\-pixels}]{\setlength{\rightskip}{0pt plus 5cm}void get\_\-spot\_\-pixels (
\begin{DoxyParamCaption}
\item[{const vector$<$ ImageRef $>$ \&}]{pixels, }
\item[{const Vector$<$ 4 $>$ \&}]{spot, }
\item[{vector$<$ int $>$ \&}]{out}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_gad0dc776b1dfaed9f8ad4d83ae6b33e56}


Which pixels belong to a given spot? Find the indices of those pixels. 



Definition at line 905 of file multispot5.cc.



Referenced by FitSpots::optimize\_\-each\_\-spot\_\-in\_\-turn\_\-for\_\-several\_\-passes(), and FitSpots::try\_\-modifying\_\-model().


\begin{DoxyCode}
{
    //Go out to three sigma

    vector<ImageRef> pix = getDisc(spot[1]*6 + 1);
    out.resize(0);
    ImageRef offset = ir_rounded(spot.slice<2,2>());
    for(unsigned int j=0; j < pix.size(); j++)
    {
        int pos = lower_bound(pixels.begin(), pixels.end(), pix[j] + offset) - pi
      xels.begin();
        if(pos != (int)pixels.size() && pixels[pos] == pix[j] + offset)
            out.push_back(pos);
    }

    if(out.size() == 0)
    {
        cout << "********************************\n";
        cout << "********************************\n";
        cout << "********************************\n";
        cout << "********************************\n";
        cout << "********************************\n";
        cout << "Oe noes!11one\n";
        cout << pix.size() << endl;
    }
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga36fa3bc23f458450a42e409d9e4f1c4f}{
\index{Storm classes@{Storm classes}!parse\_\-log\_\-file@{parse\_\-log\_\-file}}
\index{parse\_\-log\_\-file@{parse\_\-log\_\-file}!Storm classes@{Storm classes}}
\paragraph[{parse\_\-log\_\-file}]{\setlength{\rightskip}{0pt plus 5cm}{\bf StateParameters} parse\_\-log\_\-file (
\begin{DoxyParamCaption}
\item[{istream \&}]{in}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga36fa3bc23f458450a42e409d9e4f1c4f}


Parser for multispot 5 log files. 

Log files are mostly line oriented and contain various records

The main records are:

Iteraton: \#ITNUM MAIN: $<$list of spot parameters$>$

Pass: \#PASSNUM \hyperlink{structMT19937}{MT19937} $<$random number generator state$>$ PASS\#PASSNUM: $<$list of spot parameters$>$ ENDCHECKPOINT

Note that MAIN is redundant since it will be the same as the following PASS 1 (or the first pass computed if restoring from a checkpoint).

Data should only be considered valid after ENDCHECKPOINT has been read

Iteration is written once per iteration, not once per pass. (FIXME)

Which moron invented this file format???

Note that the file format hasn't beren fixed, so that the output can easily be compared to the output of the historic version which is known to be good.


\begin{DoxyParams}{Parameters}
{\em in} & Stream to parse file from \\
\hline
\end{DoxyParams}


Definition at line 1005 of file multispot5.cc.



References StateParameters::iteration, StateParameters::pass, StateParameters::pixels, StateParameters::rng, split(), StateParameters::spots, and xtoa().



Referenced by mmain().


\begin{DoxyCode}
{
    //A line read from the file
    string line;

    //State lines known to be OK
    string rngline, passline, iterationline;
    bool state_ok=0;
    
    //State lines read in, with flags of goodness
    string new_rngline, new_passline, new_iterationline;
    bool new_rngline_ok=0, new_passline_ok=0, new_iterationline_ok=0;

    unsigned int lineno=0;
    bool doing_gvars = 0;

    vector<ImageRef> pixels;

    while(!in.eof())
    {   
        getline(in, line);
        if(in.fail())
            break;
        
        lineno++;
        
        if(line == "ENDGVARLIST")
        {
            if(!doing_gvars)
                throw LogFileParseError("Spurious end of GVars");
            doing_gvars = 0;
        }
        else if(doing_gvars)
        {
            GUI.ParseLine(line);
        }
        else if(line == "BEGINGVARLIST")
        {
            doing_gvars = 1;
        }
        if(line.substr(0, 11)  == "Iteration: ")
        {
            new_iterationline = line;
            new_iterationline_ok = true;
        }
        else if(line.substr(0, 4) == "PASS")
        {
            new_passline = line;
            if(new_passline_ok)
                throw LogFileParseError("Duplicate PASS on line " + xtoa(lineno))
      ;
            new_passline_ok = true;
        }
        else if(line.substr(0, 8) == "MT19937 ")
        {
            new_rngline = line;
            if(new_rngline_ok)
                throw LogFileParseError("Duplicate MT19937 on line " + xtoa(linen
      o));
            
            new_rngline_ok = true;

        }
        else if(line == "ENDCHECKPOINT")
        {
            if(new_passline_ok && new_rngline_ok && new_iterationline_ok)
            {
                iterationline = new_iterationline;
                rngline = new_rngline;
                passline = new_passline;    
            }
            else
                throw LogFileParseError("Reached checkpoint with missing data: "
                         "it=" + xtoa(new_iterationline_ok) + 
                        " pa=" + xtoa(new_passline_ok) + 
                        " rg=" + xtoa(new_rngline_ok) + " on line " + xtoa(lineno
      ));
            
            //Don't reset iteration since it only appears once for each entire
            //set of passes. 
            new_rngline_ok = 0;
            new_passline_ok = 0;

            state_ok = true;
        }
        else if(line.substr(0, 7) == "PIXELS ")
        {
            vector<string> l = split(line);
            if( (l.size() - 1)%2 == 0)
            {
                int n = (l.size()-1)/2;
                pixels.resize(n);
                for(int i=0; i < n; i++)
                {
                    pixels[i].x = atox<int>(l[i*2+1+0], "pixels");
                    pixels[i].y = atox<int>(l[i*2+1+1], "pixels");
                }
            }
            else
                throw LogFileParseError("Bad PIXELS line");
        }
    }

    if(!state_ok)
        throw LogFileParseError("No state found");
    
    if(pixels.size() == 0)
        throw LogFileParseError("No pixels, or pixels is empty");

    //Now parse the lines
    StateParameters p;
    vector<string> l;
    
    //Parse the iterations
    l = split(iterationline);
    p.iteration = atox<int>(l[1], "iteration");

    //Parse the random number generator
    p.rng =shared_ptr<MT19937>(new MT19937);
    {
        istringstream rng_s(rngline);
        try{
            p.rng->read(rng_s);
        }
        catch(MT19937::ParseError p)
        {
            throw LogFileParseError("Error parsing MT19937");
        }
    }

    //Parse PASS and the listing of spots
    l = split(passline);
    if( (l.size() - 1 ) % 4 == 0)
    {
        p.pass = atox<int>(l[0].substr(4), "pass");

        for(unsigned int i=0; i < (l.size()-1)/4; i++)
        {
            cout << l[i*4+1+0] << endl;
            cout << l[i*4+1+1] << endl;
            cout << l[i*4+1+2] << endl;
            cout << l[i*4+1+3] << endl;
            p.spots.push_back(makeVector(
                        atox<double>(l[i*4+1+0], "spot"),
                        atox<double>(l[i*4+1+1], "spot"),
                        atox<double>(l[i*4+1+2], "spot"),
                        atox<double>(l[i*4+1+3], "spot")));
        }

    }
    else
        throw LogFileParseError("Wrong number of elements in PASS line");

    //Set up the pixels (oh god the pixels)
    p.pixels = pixels;

    return p;   
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga4aa9ab83b786fd72995cfa21c3f0861d}{
\index{Storm classes@{Storm classes}!brightness\_\-motion\_\-limit@{brightness\_\-motion\_\-limit}}
\index{brightness\_\-motion\_\-limit@{brightness\_\-motion\_\-limit}!Storm classes@{Storm classes}}
\paragraph[{brightness\_\-motion\_\-limit}]{\setlength{\rightskip}{0pt plus 5cm}double brightness\_\-motion\_\-limit (
\begin{DoxyParamCaption}
\item[{double}]{mu, }
\item[{double}]{sigma, }
\item[{bool}]{not\_\-one}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga4aa9ab83b786fd72995cfa21c3f0861d}


How far should steps in brightness be limited to? 



Definition at line 1353 of file multispot5.cc.



References log\_\-normal\_\-std().


\begin{DoxyCode}
{
    if(not_one)
        return log_normal_std(mu, sigma);
    else
        return 1;
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga55c141b3f0c10f7046c69497ec29c50d}{
\index{Storm classes@{Storm classes}!fit\_\-spots\_\-new@{fit\_\-spots\_\-new}}
\index{fit\_\-spots\_\-new@{fit\_\-spots\_\-new}!Storm classes@{Storm classes}}
\paragraph[{fit\_\-spots\_\-new}]{\setlength{\rightskip}{0pt plus 5cm}void fit\_\-spots\_\-new (
\begin{DoxyParamCaption}
\item[{const vector$<$ Image$<$ float $>$ $>$ \&}]{ims, }
\item[{{\bf StateParameters} \&}]{p, }
\item[{ofstream \&}]{save\_\-spots, }
\item[{{\bf FitSpotsGraphics} \&}]{gr}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga55c141b3f0c10f7046c69497ec29c50d}


Wrapper function for using \hyperlink{classFitSpots}{FitSpots}. 



Definition at line 2100 of file multispot5.cc.



References null\_\-ui(), and FitSpots::run().



Referenced by mmain().


\begin{DoxyCode}
{
    auto_ptr<UserInterfaceCallback> ui = null_ui();
    FitSpots fit(ims, gr, *ui, p, save_spots);
    fit.run();
}
\end{DoxyCode}
\hypertarget{group__gStorm_gaf79c717a2e7addbc7455dd79ea958eb5}{
\index{Storm classes@{Storm classes}!fit\_\-spots\_\-new@{fit\_\-spots\_\-new}}
\index{fit\_\-spots\_\-new@{fit\_\-spots\_\-new}!Storm classes@{Storm classes}}
\paragraph[{fit\_\-spots\_\-new}]{\setlength{\rightskip}{0pt plus 5cm}void fit\_\-spots\_\-new (
\begin{DoxyParamCaption}
\item[{const vector$<$ Image$<$ float $>$ $>$ \&}]{ims, }
\item[{{\bf StateParameters} \&}]{p, }
\item[{ofstream \&}]{save\_\-spots, }
\item[{{\bf FitSpotsGraphics} \&}]{gr, }
\item[{{\bf UserInterfaceCallback} \&}]{ui}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_gaf79c717a2e7addbc7455dd79ea958eb5}


Wrapper function for using \hyperlink{classFitSpots}{FitSpots}. 



Definition at line 2109 of file multispot5.cc.



References FitSpots::run().


\begin{DoxyCode}
{
    try{
        FitSpots fit(ims, gr, ui, p, save_spots);
        fit.run();
    }
    catch(UserInterfaceCallback::UserIssuedStop)
    {
    }
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga0b300e882aad6e3c180df8f58bd5bf63}{
\index{Storm classes@{Storm classes}!spot\_\-shape\_\-s@{spot\_\-shape\_\-s}}
\index{spot\_\-shape\_\-s@{spot\_\-shape\_\-s}!Storm classes@{Storm classes}}
\paragraph[{spot\_\-shape\_\-s}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class B $>$ double spot\_\-shape\_\-s (
\begin{DoxyParamCaption}
\item[{const TooN::Vector$<$ 2 $>$ \&}]{x, }
\item[{const TooN::Vector$<$ 4, double, B $>$ \&}]{phi}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga0b300e882aad6e3c180df8f58bd5bf63}


See \hyperlink{group__gStorm_ga4414bdd28d7ba4d708f3b329d7a2abad}{spot\_\-shape()} 


\begin{DoxyParams}{Parameters}
{\em x} & $\Vec{x}$ \\
\hline
{\em phi} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$s(\Vec{x}, \Vec{\phi}) $ 
\end{DoxyReturn}


Definition at line 36 of file storm.h.



Referenced by spot\_\-shape(), spot\_\-shape\_\-diff(), spot\_\-shape\_\-diff\_\-position(), spot\_\-shape\_\-hess(), and spot\_\-shape\_\-hess\_\-position().


\begin{DoxyCode}
{
    return -norm_sq(x - phi.template slice<2,2>()) / (2*phi[1]*phi[1]);
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga6b2081a450ccc5950ae17115bf7a0c56}{
\index{Storm classes@{Storm classes}!spot\_\-shape\_\-diff\_\-position@{spot\_\-shape\_\-diff\_\-position}}
\index{spot\_\-shape\_\-diff\_\-position@{spot\_\-shape\_\-diff\_\-position}!Storm classes@{Storm classes}}
\paragraph[{spot\_\-shape\_\-diff\_\-position}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class B $>$ std::pair$<$double, TooN::Vector$<$4$>$ $>$ spot\_\-shape\_\-diff\_\-position (
\begin{DoxyParamCaption}
\item[{const TooN::Vector$<$ 2 $>$ \&}]{x, }
\item[{const TooN::Vector$<$ 4, double, B $>$ \&}]{phi}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga6b2081a450ccc5950ae17115bf7a0c56}


Compute the spot shape and its derivative with respect to posision. 

See also \hyperlink{group__gStorm_ga4414bdd28d7ba4d708f3b329d7a2abad}{spot\_\-shape()} 
\begin{DoxyParams}{Parameters}
{\em x} & $\Vec{x}$ \\
\hline
{\em phi} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}


Definition at line 46 of file storm.h.



References spot\_\-shape\_\-s(), and sq().


\begin{DoxyCode}
{
    using namespace TooN;

    double s = spot_shape_s(x, phi);
    double r_2_pi = sqrt(2*M_PI);

    double prob = exp(s) * phi[0]/(phi[1]*r_2_pi);
    
    Vector<4> deriv = (exp(s) / (phi[1]*r_2_pi)) * 
                           makeVector(1, 
                                      -phi[0] * (1 + 2*s)/phi[1], 
                                      (x[0] - phi[2])*(phi[0]/sq(phi[1])), 
                                      (x[1] - phi[3])*(phi[0]/sq(phi[1])));
    return std::make_pair(prob, deriv);
}
\end{DoxyCode}
\hypertarget{group__gStorm_gaf4680f7b58ed5c458939e464c4ead582}{
\index{Storm classes@{Storm classes}!spot\_\-shape\_\-hess\_\-position@{spot\_\-shape\_\-hess\_\-position}}
\index{spot\_\-shape\_\-hess\_\-position@{spot\_\-shape\_\-hess\_\-position}!Storm classes@{Storm classes}}
\paragraph[{spot\_\-shape\_\-hess\_\-position}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class B $>$ std::tr1::tuple$<$double, TooN::Vector$<$4$>$, TooN::Matrix$<$4$>$ $>$ spot\_\-shape\_\-hess\_\-position (
\begin{DoxyParamCaption}
\item[{const TooN::Vector$<$ 2 $>$ \&}]{x, }
\item[{const TooN::Vector$<$ 4, double, B $>$ \&}]{phi}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_gaf4680f7b58ed5c458939e464c4ead582}


Compute the spot shape and its Hessian with respect to posision. 

See also \hyperlink{group__gStorm_ga4414bdd28d7ba4d708f3b329d7a2abad}{spot\_\-shape()} 
\begin{DoxyParams}{Parameters}
{\em x} & $\Vec{x}$ \\
\hline
{\em phi} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}


Definition at line 68 of file storm.h.



References spot\_\-shape\_\-s(), and sq().


\begin{DoxyCode}
{
    using namespace TooN;
    using namespace std::tr1;

    double s = spot_shape_s(x, phi);
    double r_2_pi = sqrt(2*M_PI);

    double es = exp(s);

    double prob = es * phi[0]/(phi[1]*r_2_pi);
    
    Vector<4> deriv = (es / (phi[1]*r_2_pi)) * 
                           makeVector(1, 
                                      -phi[0] * (1 + 2*s)/phi[1], 
                                      (x[0] - phi[2])*(phi[0]/sq(phi[1])), 
                                      (x[1] - phi[3])*(phi[0]/sq(phi[1])));

    Matrix<4> hess;
    hess[0][0] = 0;

    hess[0][1] = -es*(1+2*s) / (phi[1] * phi[1] * r_2_pi);
    hess[1][0] = hess[0][1];

    hess[0][2] = es * (x[0] - phi[2]) / (pow(phi[1], 3)*r_2_pi);
    hess[2][0] = es * (x[0] - phi[2]) / (pow(phi[1], 3)*r_2_pi);

    hess[0][3] = es * (x[1] - phi[3]) / (pow(phi[1], 3)*r_2_pi);
    hess[3][0] = es * (x[1] - phi[3]) / (pow(phi[1], 3)*r_2_pi);

    hess[1][1] = 2*phi[0]*es*(1 + 5*s + 2*s*s) / ( pow(phi[1], 3) * r_2_pi);

    hess[1][2] = -phi[0] * es * (3 + 2*s) * (x[0] - phi[2]) / (pow(phi[1], 4) * r
      _2_pi);
    hess[1][3] = -phi[0] * es * (3 + 2*s) * (x[1] - phi[3]) / (pow(phi[1], 4) * r
      _2_pi);

    hess[2][1] = hess[1][2];
    hess[3][1] = hess[1][3];

    hess[2][2] = phi[0] * es * (sq(x[0] - phi[2]) - sq(phi[1])) / (r_2_pi * pow(p
      hi[1], 5));
    hess[3][3] = phi[0] * es * (sq(x[1] - phi[3]) - sq(phi[1])) / (r_2_pi * pow(p
      hi[1], 5));
    
    hess[2][3] = phi[0] * es * (x[0] - phi[2])*(x[1] - phi[3]) / (r_2_pi * pow(ph
      i[1], 5));
    hess[3][2] = hess[2][3];


    return make_tuple(prob, deriv, hess);
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga110d3db1cf9bdb79a56498e6506c7c19}{
\index{Storm classes@{Storm classes}!spot\_\-shape\_\-hess@{spot\_\-shape\_\-hess}}
\index{spot\_\-shape\_\-hess@{spot\_\-shape\_\-hess}!Storm classes@{Storm classes}}
\paragraph[{spot\_\-shape\_\-hess}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class B $>$ std::tr1::tuple$<$double, TooN::Vector$<$2$>$, TooN::Matrix$<$2$>$ $>$ spot\_\-shape\_\-hess (
\begin{DoxyParamCaption}
\item[{const TooN::Vector$<$ 2 $>$ \&}]{x, }
\item[{const TooN::Vector$<$ 4, double, B $>$ \&}]{phi}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga110d3db1cf9bdb79a56498e6506c7c19}


Value of the spot, given the parameters and input location. 

The spot is described by the following formula: \[ \mu(\Vec{x}, \Vec{\phi}) = \frac{\phi_1}{\phi_2\sqrt(2\pi)} e^s, \] where \[ s = -\frac{(x_1 - \phi_3)^2 + (x_2 - \phi_4)^2}{2\phi_2^2}. \] This describes a generic blobby spot function of a variable size. The light output can be tuned by varying $\phi_1$, and the level of blur can be changed independently by varying $\phi_2$. The derivative is: \begin{eqnarray} \frac{\partial \mu}{\partial \phi_1} &=& \frac{1}{\phi_2\sqrt{2\pi}}e^s\\ \frac{\partial \mu}{\partial \phi_2} &=& -\frac{\phi_1}{\phi_2^2\sqrt{2\pi}}e^s(1 + 2s) \end{eqnarray} And the hessian is: \begin{eqnarray} \frac{\partial^2 \mu}{\partial \phi_1^2} &=& 0\\ \frac{\partial^2 \mu}{\partial\phi_1 \partial \phi_2} &=& -\frac{1}{\phi_2^2\sqrt{2\pi}}e^s(1 + 2s)\\ \frac{\partial^2 \mu}{\partial \phi_2^2} &=& \frac{2\phi_1}{\phi_2^3\sqrt{2\pi}}e^s(1 + 5s + 2s^2) \end{eqnarray} 
\begin{DoxyParams}{Parameters}
{\em x} & $\Vec{x}$ \\
\hline
{\em phi} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$\mu(\Vec{x}, \Vec{\phi}) $ 
\end{DoxyReturn}


Definition at line 143 of file storm.h.



References spot\_\-shape\_\-s().



Referenced by log\_\-probability\_\-spot\_\-hess().


\begin{DoxyCode}
{
    double s = spot_shape_s(x, phi);
    double r_2_pi = sqrt(2*M_PI);

    double prob = exp(s) * phi[0]/(phi[1]*r_2_pi);
    TooN::Vector<2> deriv = (exp(s) / (phi[1]*r_2_pi)) * TooN::makeVector(1, -phi
      [0] * (1 + 2*s)/phi[1]);
    TooN::Matrix<2> hess;

    hess[0][0] = 0;
    hess[0][1] = -exp(s)*(1+2*s) / (phi[1] * phi[1] * r_2_pi);
    hess[1][0] = hess[0][1];
    hess[1][1] = 2*phi[0]*exp(s)*(1 + 5*s + 2*s*s) / ( pow(phi[1], 3) * r_2_pi);

    return std::tr1::make_tuple(prob, deriv, hess);
}
\end{DoxyCode}
\hypertarget{group__gStorm_gafbd0826fe088e857f2e97105efa8ef6e}{
\index{Storm classes@{Storm classes}!spot\_\-shape\_\-diff@{spot\_\-shape\_\-diff}}
\index{spot\_\-shape\_\-diff@{spot\_\-shape\_\-diff}!Storm classes@{Storm classes}}
\paragraph[{spot\_\-shape\_\-diff}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class B $>$ std::pair$<$double, TooN::Vector$<$2$>$ $>$ spot\_\-shape\_\-diff (
\begin{DoxyParamCaption}
\item[{const TooN::Vector$<$ 2 $>$ \&}]{x, }
\item[{const TooN::Vector$<$ 4, double, B $>$ \&}]{phi}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_gafbd0826fe088e857f2e97105efa8ef6e}


see \hyperlink{group__gStorm_ga110d3db1cf9bdb79a56498e6506c7c19}{spot\_\-shape\_\-hess()} 


\begin{DoxyParams}{Parameters}
{\em x} & $\Vec{x}$ \\
\hline
{\em phi} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$\mu(\Vec{x}, \Vec{\phi}) $ 
\end{DoxyReturn}


Definition at line 165 of file storm.h.



References spot\_\-shape\_\-s().



Referenced by log\_\-probability\_\-spot\_\-diff().


\begin{DoxyCode}
{
    double s = spot_shape_s(x, phi);
    double r_2_pi = sqrt(2*M_PI);

    double prob = exp(s) * phi[0]/(phi[1]*r_2_pi);
    TooN::Vector<2> deriv = (exp(s) / (phi[1]*r_2_pi)) * TooN::makeVector(1, -phi
      [0] * (1 + 2*s)/phi[1]);
    return std::make_pair(prob, deriv);
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga4414bdd28d7ba4d708f3b329d7a2abad}{
\index{Storm classes@{Storm classes}!spot\_\-shape@{spot\_\-shape}}
\index{spot\_\-shape@{spot\_\-shape}!Storm classes@{Storm classes}}
\paragraph[{spot\_\-shape}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class B $>$ double spot\_\-shape (
\begin{DoxyParamCaption}
\item[{const TooN::Vector$<$ 2 $>$ \&}]{x, }
\item[{const TooN::Vector$<$ 4, double, B $>$ \&}]{phi}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga4414bdd28d7ba4d708f3b329d7a2abad}


see \hyperlink{group__gStorm_ga110d3db1cf9bdb79a56498e6506c7c19}{spot\_\-shape\_\-hess()} 


\begin{DoxyParams}{Parameters}
{\em x} & $\Vec{x}$ \\
\hline
{\em phi} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$\mu(\Vec{x}, \Vec{\phi}) $ 
\end{DoxyReturn}


Definition at line 181 of file storm.h.



References spot\_\-shape\_\-s().



Referenced by log\_\-probability\_\-spot().


\begin{DoxyCode}
{
    double s = spot_shape_s(x, phi);
    double r_2_pi = sqrt(2*M_PI);
    
    // FIXME FIXME FIXME and don't forget to fix the HESSIAN AND DERIVATIVE
    // Should be:              1/(2 pi s^2)  for two dimensions
    //                             vvvvvvvvvvvvv    http://lol.i.trollyou.com/
    double prob = exp(s) * phi[0]/(phi[1]*r_2_pi);


    return prob;
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga5d0cd4c20daf3c1eb6bfa65d655d0243}{
\index{Storm classes@{Storm classes}!log\_\-probability\_\-spot\_\-hess@{log\_\-probability\_\-spot\_\-hess}}
\index{log\_\-probability\_\-spot\_\-hess@{log\_\-probability\_\-spot\_\-hess}!Storm classes@{Storm classes}}
\paragraph[{log\_\-probability\_\-spot\_\-hess}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Base $>$ std::tr1::tuple$<$double, TooN::Vector$<$2$>$, TooN::Matrix$<$2$>$ $>$ log\_\-probability\_\-spot\_\-hess (
\begin{DoxyParamCaption}
\item[{const CVD::SubImage$<$ float $>$ \&}]{im, }
\item[{double}]{variance, }
\item[{const TooN::Vector$<$ 4, double, Base $>$ \&}]{spot\_\-parameters}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga5d0cd4c20daf3c1eb6bfa65d655d0243}


Find the log probability of an image patch, assuming zero base-\/line mean and the given variance. 

This function makes use of the spot shape. It is assumed that the centre pixel of the image is at 0,0. Since the noise is Gaussian: \begin{eqnarray} P(\text{image}) &=& \prod_{\Vec{x} \in \text{pixels}} \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(I(\Vec{x}) - \mu(\Vec{x}, \Vec{\phi}))^2}{2\sigma^2}} \\ \ln P(\text{image}) &=& \sum_{\Vec{x} \in \text{pixels}} -\frac{(I(\Vec{x}) - \mu(\Vec{x}, \Vec{\phi}))^2}{2\sigma^2} - \frac{N}{2} \ln {2 \pi \sigma^2}, \end{eqnarray} where {\itshape I\/} is the image, and {\itshape N\/} is the number of pixels. See also \hyperlink{storm_8h_af75ebcfbdf0264151f425435ba3d26e1}{log\_\-probability\_\-no\_\-spot} and $\mu$ (\hyperlink{group__gStorm_ga4414bdd28d7ba4d708f3b329d7a2abad}{spot\_\-shape}). The derivatives are: \begin{eqnarray} \frac{\partial \ln P(I)}{\partial \phi_0} &=& \frac{1}{\sigma^2} \sum_{\Vec{x}}(I_{\Vec{x}} - \mu(\Vec{x},\Vec{\phi})) \frac{\partial}{\partial \phi_0}\mu(\Vec{x}, \Vec{\phi})\\ \frac{\partial^2 \ln P(I)}{\partial \phi_0 \partial \phi_1} &=& \frac{1}{\sigma^2} \sum_{\Vec{x}}(I_{\Vec{x}} - \mu(\Vec{x},\Vec{\phi})) \frac{\partial^2}{\partial \phi_0 \partial \phi_1}\mu(\Vec{x}, \Vec{\phi}) - \frac{\partial}{\partial \phi_0}\mu(\Vec{x},\Vec{\phi}) \frac{\partial}{\partial \phi_1}\mu(\Vec{x},\Vec{\phi}) \end{eqnarray}


\begin{DoxyParams}{Parameters}
{\em im} & Image \\
\hline
{\em variance} & $\sigma^2$ \\
\hline
{\em spot\_\-parameters} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The log probability 
\end{DoxyReturn}


Definition at line 236 of file storm.h.



References spot\_\-shape\_\-hess(), and sq().


\begin{DoxyCode}
{
    using namespace TooN;
    using namespace std::tr1;

    //-1 because if the image is 3x3, ie 0,1,2 then 1,1 is the centre.
    //If it is 2x2, ie 0,1 then .5,.5 is the centre
    Vector<2> centre = makeVector((im.size().x-1) / 2.0, (im.size().y-1) / 2.0);

    double logprob_part=0;
    Vector<2> diff = Zeros;
    Matrix<2> hess = Zeros;
    for(int y=0; y < im.size().y; y++)
        for(int x=0; x < im.size().x; x++)
        {
            Vector<2> d = TooN::makeVector(x, y) - centre;

            double mu;
            Vector<2> diff_mu;
            Matrix<2> hess_mu;
            tie(mu, diff_mu, hess_mu) = spot_shape_hess(d, spot_parameters);

            double e = im[y][x] - mu;

            logprob_part += -sq(e);
            diff         += diff_mu * e;
            hess         += e * hess_mu - diff_mu.as_col() * diff_mu.as_row();
        }
    return make_tuple(   logprob_part / (2*variance) - im.size().area() * log(2*M
      _PI*variance)/2,
                        diff / variance,
                        hess / variance);
}
\end{DoxyCode}
\hypertarget{group__gStorm_gabab1ab1b780d7da267c5dccaef0b87c9}{
\index{Storm classes@{Storm classes}!log\_\-probability\_\-spot\_\-diff@{log\_\-probability\_\-spot\_\-diff}}
\index{log\_\-probability\_\-spot\_\-diff@{log\_\-probability\_\-spot\_\-diff}!Storm classes@{Storm classes}}
\paragraph[{log\_\-probability\_\-spot\_\-diff}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Base $>$ std::pair$<$double, TooN::Vector$<$2$>$ $>$ log\_\-probability\_\-spot\_\-diff (
\begin{DoxyParamCaption}
\item[{const CVD::SubImage$<$ float $>$ \&}]{im, }
\item[{double}]{variance, }
\item[{const TooN::Vector$<$ 4, double, Base $>$ \&}]{spot\_\-parameters}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_gabab1ab1b780d7da267c5dccaef0b87c9}


See log\_\-probability\_\-spot\_\-hess. 


\begin{DoxyParams}{Parameters}
{\em im} & Image \\
\hline
{\em variance} & $\sigma^2$ \\
\hline
{\em spot\_\-parameters} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The log probability 
\end{DoxyReturn}


Definition at line 276 of file storm.h.



References spot\_\-shape\_\-diff(), and sq().


\begin{DoxyCode}
{
    using namespace TooN;
    using namespace std::tr1;
    using namespace std;
    //-1 because if the image is 3x3, ie 0,1,2 then 1,1 is the centre.
    //If it is 2x2, ie 0,1 then .5,.5 is the centre
    Vector<2> centre = makeVector((im.size().x-1) / 2.0, (im.size().y-1) / 2.0);

    double logprob_part=0;
    Vector<2> diff = Zeros;
    for(int y=0; y < im.size().y; y++)
        for(int x=0; x < im.size().x; x++)
        {
            Vector<2> d = makeVector(x, y) - centre;

            double mu;
            Vector<2> diff_mu;
            tie(mu, diff_mu) = spot_shape_diff(d, spot_parameters);

            double e = im[y][x] - mu;

            logprob_part += -sq(e);
            diff         += diff_mu * e;
        }
    return make_pair(logprob_part / (2*variance) - im.size().area() * log(2*M_PI*
      variance)/2, diff / variance);
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga1a24bd3f98cfef3265ec27f522b790eb}{
\index{Storm classes@{Storm classes}!log\_\-probability\_\-spot@{log\_\-probability\_\-spot}}
\index{log\_\-probability\_\-spot@{log\_\-probability\_\-spot}!Storm classes@{Storm classes}}
\paragraph[{log\_\-probability\_\-spot}]{\setlength{\rightskip}{0pt plus 5cm}template$<$class Base $>$ double log\_\-probability\_\-spot (
\begin{DoxyParamCaption}
\item[{const CVD::SubImage$<$ float $>$ \&}]{im, }
\item[{double}]{variance, }
\item[{const TooN::Vector$<$ 4, double, Base $>$ \&}]{spot\_\-parameters}
\end{DoxyParamCaption}
)}}
\label{group__gStorm_ga1a24bd3f98cfef3265ec27f522b790eb}


See log\_\-probability\_\-spot\_\-hess. 


\begin{DoxyParams}{Parameters}
{\em im} & Image \\
\hline
{\em variance} & $\sigma^2$ \\
\hline
{\em spot\_\-parameters} & $\Vec{\phi}$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The log probability 
\end{DoxyReturn}


Definition at line 311 of file storm.h.



References spot\_\-shape(), and sq().


\begin{DoxyCode}
{
    //-1 because if the image is 3x3, ie 0,1,2 then 1,1 is the centre.
    //If it is 2x2, ie 0,1 then .5,.5 is the centre
    TooN::Vector<2> centre = TooN::makeVector((im.size().x-1) / 2.0, (im.size().y
      -1) / 2.0);

    double logprob_part=0;
    for(int y=0; y < im.size().y; y++)
        for(int x=0; x < im.size().x; x++)
        {
            TooN::Vector<2> d = TooN::makeVector(x, y) - centre;

            double mu = spot_shape(d, spot_parameters);

            double e = im[y][x] - mu;

            logprob_part += -sq(e);
        }
    return logprob_part / (2*variance) - im.size().area() * log(2*M_PI*variance)/
      2;
}
\end{DoxyCode}
\hypertarget{group__gStorm_gac9fd2f658c90bcf942fde135dab63557}{
\index{Storm classes@{Storm classes}!log\_\-normal\_\-std@{log\_\-normal\_\-std}}
\index{log\_\-normal\_\-std@{log\_\-normal\_\-std}!Storm classes@{Storm classes}}
\paragraph[{log\_\-normal\_\-std}]{\setlength{\rightskip}{0pt plus 5cm}double log\_\-normal\_\-std (
\begin{DoxyParamCaption}
\item[{double}]{mu, }
\item[{double}]{sigma}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{group__gStorm_gac9fd2f658c90bcf942fde135dab63557}


Compute the standard deviation of a log-\/normal distribution. 

See log\_\-normal(). \begin{equation} \mathrm{Var}[P(x)] = (e^(\sigma^2)-1)e^(2*\mu+\sigma^2) \end{equation} 
\begin{DoxyParams}{Parameters}
{\em sigma} & $ \sigma$ \\
\hline
{\em mu} & $ \mu$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The standard deviation 
\end{DoxyReturn}


Definition at line 343 of file storm.h.



References sq().



Referenced by brightness\_\-motion\_\-limit().


\begin{DoxyCode}
{
    return sqrt((exp(sq(sigma)) - 1) * exp(2*mu + sq(sigma)));
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga69425e80deea70f9bd15cc82b50768a3}{
\index{Storm classes@{Storm classes}!log\_\-normal\_\-mode@{log\_\-normal\_\-mode}}
\index{log\_\-normal\_\-mode@{log\_\-normal\_\-mode}!Storm classes@{Storm classes}}
\paragraph[{log\_\-normal\_\-mode}]{\setlength{\rightskip}{0pt plus 5cm}double log\_\-normal\_\-mode (
\begin{DoxyParamCaption}
\item[{double}]{mu, }
\item[{double}]{sigma}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{group__gStorm_ga69425e80deea70f9bd15cc82b50768a3}


Compute the mode of a log-\/normal distribution. 

See log\_\-normal(). \begin{equation} \mathrm{Mode}[P(x)] = e^(\mu-\sigma^2) \end{equation} 
\begin{DoxyParams}{Parameters}
{\em sigma} & $ \sigma$ \\
\hline
{\em mu} & $ \mu$ \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The mode 
\end{DoxyReturn}


Definition at line 359 of file storm.h.



Referenced by generate\_\-state\_\-parameters\_\-ye\_\-olde(), and FitSpots::try\_\-modifying\_\-model().


\begin{DoxyCode}
{
    return exp(mu - sigma * sigma);
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga110afd744fdb0f40c6420b640f05a61c}{
\index{Storm classes@{Storm classes}!log\_\-log\_\-normal@{log\_\-log\_\-normal}}
\index{log\_\-log\_\-normal@{log\_\-log\_\-normal}!Storm classes@{Storm classes}}
\paragraph[{log\_\-log\_\-normal}]{\setlength{\rightskip}{0pt plus 5cm}double log\_\-log\_\-normal (
\begin{DoxyParamCaption}
\item[{double}]{x, }
\item[{double}]{mu, }
\item[{double}]{sigma}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{group__gStorm_ga110afd744fdb0f40c6420b640f05a61c}


Log-\/normal distribution. 

This is given by: \begin{eqnarray} P(x) &=& \frac{1}{x\sigma\sqrt{2\pi}} e^{-\frac{(\ln x - \mu)^2}{s\sigma^2}}\\ \ln P(x) &=& -\frac{(\ln x - \mu)^2}{s\sigma^2} - \ln x - \ln\sigma\sqrt{2\pi}. \end{eqnarray} 
\begin{DoxyParams}{Parameters}
{\em x} & {\itshape x\/} \\
\hline
{\em mu} & $\mu$ \\
\hline
{\em sigma} & $\sigma$ \\
\hline
\end{DoxyParams}


Definition at line 374 of file storm.h.



References ln(), and sq().



Referenced by NegativeFreeEnergy::compute\_\-with\_\-mask(), and NegativeFreeEnergy::operator()().


\begin{DoxyCode}
{
    return -sq(ln(x) - mu) / (2*sq(sigma)) - ln(x) - ln(sigma * sqrt(2*M_PI));
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga3a78c1d136f9878f2a14cd03ffcd6ba7}{
\index{Storm classes@{Storm classes}!diff\_\-log\_\-log\_\-normal@{diff\_\-log\_\-log\_\-normal}}
\index{diff\_\-log\_\-log\_\-normal@{diff\_\-log\_\-log\_\-normal}!Storm classes@{Storm classes}}
\paragraph[{diff\_\-log\_\-log\_\-normal}]{\setlength{\rightskip}{0pt plus 5cm}double diff\_\-log\_\-log\_\-normal (
\begin{DoxyParamCaption}
\item[{double}]{x, }
\item[{double}]{mu, }
\item[{double}]{sigma}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{group__gStorm_ga3a78c1d136f9878f2a14cd03ffcd6ba7}


Derivative of the log of the log-\/normal distribution: \[ \frac{\partial \ln P(x)}{\partial x} = -\frac{1}{x}\left(1 + \frac{\ln x - \mu}{\sigma^2}\right). \]. 


\begin{DoxyParams}{Parameters}
{\em x} & {\itshape x\/} \\
\hline
{\em mu} & $\mu$ \\
\hline
{\em sigma} & $\sigma$ \\
\hline
\end{DoxyParams}


Definition at line 388 of file storm.h.



References ln(), and sq().



Referenced by FreeEnergyHessian::hessian(), SpotNegProbabilityDiffWithSampledBackground::operator()(), sampled\_\-background\_\-spot\_\-hessian2(), and sampled\_\-background\_\-spot\_\-hessian\_\-ffbs().


\begin{DoxyCode}
{
    return -(1 + (ln(x) - mu)/sq(sigma)) / x;
}
\end{DoxyCode}
\hypertarget{group__gStorm_ga132079a5bc2e1971da76daed8c010d2a}{
\index{Storm classes@{Storm classes}!hess\_\-log\_\-log\_\-normal@{hess\_\-log\_\-log\_\-normal}}
\index{hess\_\-log\_\-log\_\-normal@{hess\_\-log\_\-log\_\-normal}!Storm classes@{Storm classes}}
\paragraph[{hess\_\-log\_\-log\_\-normal}]{\setlength{\rightskip}{0pt plus 5cm}double hess\_\-log\_\-log\_\-normal (
\begin{DoxyParamCaption}
\item[{double}]{x, }
\item[{double}]{mu, }
\item[{double}]{sigma}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{group__gStorm_ga132079a5bc2e1971da76daed8c010d2a}


Second derivative of the log of the log-\/normal distribution: \[ \frac{\partial^2 \ln P(x)}{\partial x^2} = \frac{1}{x^2}\left(1 + \frac{\ln x - \mu}{\sigma^2} - \frac{1}{\sigma^2}\right). \]. 


\begin{DoxyParams}{Parameters}
{\em x} & {\itshape x\/} \\
\hline
{\em mu} & $\mu$ \\
\hline
{\em sigma} & $\sigma$ \\
\hline
\end{DoxyParams}


Definition at line 403 of file storm.h.



References ln(), and sq().



Referenced by FreeEnergyHessian::hessian(), sampled\_\-background\_\-spot\_\-hessian2(), sampled\_\-background\_\-spot\_\-hessian\_\-FAKE(), and sampled\_\-background\_\-spot\_\-hessian\_\-ffbs().


\begin{DoxyCode}
{
    return (1 + (ln(x) - mu - 1)/sq(sigma)) / sq(x);
}
\end{DoxyCode}
