ToPS
DiscreteIIDModel.hpp
00001 /*
00002  *       DiscreteIIDModel.hpp
00003  *
00004  *       Copyright 2011 Andre Yoshiaki Kashiwabara <akashiwabara@usp.br>
00005  *                      Ígor Bonádio <ibonadio@ime.usp.br>
00006  *                      Vitor Onuchic <vitoronuchic@gmail.com>
00007  *                      Alan Mitchell Durham <aland@usp.br>
00008  *
00009  *       This program is free software; you can redistribute it and/or modify
00010  *       it under the terms of the GNU  General Public License as published by
00011  *       the Free Software Foundation; either version 3 of the License, or
00012  *       (at your option) any later version.
00013  *
00014  *       This program is distributed in the hope that it will be useful,
00015  *       but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *       GNU General Public License for more details.
00018  *
00019  *       You should have received a copy of the GNU General Public License
00020  *       along with this program; if not, write to the Free Software
00021  *       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022  *       MA 02110-1301, USA.
00023  */
00024 
00025 #ifndef FINITE_DISCRETE_DISTRIBUTION_H
00026 #define FINITE_DISCRETE_DISTRIBUTION_H
00027 
00028 #include "crossplatform.hpp"
00029 
00030 #include "Sequence.hpp"
00031 #include "Alphabet.hpp"
00032 
00033 #include "ProbabilisticModel.hpp"
00034 #include "FactorableModel.hpp"
00035 #include "util.hpp"
00036 #include <cstdarg>
00037 #include <vector>
00038 
00039 namespace tops {
00040 
00042   class DLLEXPORT DiscreteIIDModel :  public FactorableModel
00043   {
00044   private:
00045     DoubleVector _log_probabilities;
00046     Matrix _log_probabilities_matrix;
00047     double _huge_;
00048     int _size;
00049     bool _geometric_tail;
00050     double _mean;
00051   public:
00052 
00053     DiscreteIIDModel()  {
00054       _geometric_tail = false;
00055     };
00057 
00058     DiscreteIIDModel(const DoubleVector & probabilities) ;
00059 
00060 
00061 
00062     DiscreteIIDModel(const Matrix & probabilities);
00063 
00065     virtual double choose()const ;
00066 
00067     virtual void choosePair(int* a, int* b)const;
00068 
00070     virtual double log_probability_of(int s) const;
00071 
00072     virtual double log_probability_of_pair(int s1, int s2) const;
00073 
00074     void strMatrix () const;
00075 
00077     virtual double log_probability_of(int s, double new_value) ;
00078 
00079 
00080     virtual double evaluatePosition(const Sequence & s, unsigned int i) const ;
00081 
00082     virtual double log_probability_of_pair(int s1, int s2, double new_value);
00083 
00084     virtual double choosePosition(const Sequence & s, int i )const ;
00085 
00086     virtual std::string model_name() const {
00087       return "DiscreteIIDModel";
00088     }
00089 
00090     virtual ProbabilisticModelCreatorPtr getFactory () const;
00091 
00092     virtual int size() const;
00093     virtual std::string str() const;
00094 
00095     virtual void initializeFromMap(const std::map <std::string, double> & probabilities, AlphabetPtr alphabet) ;
00096 
00097     virtual void initialize(const ProbabilisticModelParameters & p) ;
00098 
00099     virtual ProbabilisticModelParameters parameters() const;
00100 
00101     void setProbabilities(const DoubleVector & probabilities) ;
00102   };
00103 
00104   typedef boost::shared_ptr<DiscreteIIDModel> DiscreteIIDModelPtr;
00105 }
00106 
00107 
00108 #endif