| 653 | |
| 654 | /*! Log-Normal probability density |
| 655 | only allow diagonal covariances! |
| 656 | |
| 657 | Density of the form \f$ \log(x)\sim \mathcal{N}(\mu,\sigma^2), i.e. |
| 658 | \f[ |
| 659 | x \sim \frac{1}{x\sigma\sqrt{2\pi}}\exp{-\frac{1}{2\sigma^2}(\log(x)-\mu)} |
| 660 | \f] |
| 661 | |
| 662 | */ |
| 663 | class elognorm: public enorm<ldmat>{ |
| 664 | public: |
| 665 | vec sample() const {return exp(enorm<ldmat>::sample());}; |
| 666 | vec mean() const {vec var=enorm<ldmat>::variance();return exp(mu - 0.5*var);}; |
| 667 | |
| 668 | }; |
| 669 | |
| 670 | /*! |
| 671 | \brief Log-Normal random walk |
| 672 | |
| 673 | Mean value, \f$\mu\f$, is... |
| 674 | |
| 675 | ==== Check == vv = |
| 676 | Standard deviation of the random walk is proportional to one \f$k\f$-th the mean. |
| 677 | This is achieved by setting \f$\alpha=k\f$ and \f$\beta=k/\mu\f$. |
| 678 | |
| 679 | The standard deviation of the walk is then: \f$\mu/\sqrt(k)\f$. |
| 680 | */ |
| 681 | class mlognorm : public mpdf { |
| 682 | protected: |
| 683 | elognorm eno; |
| 684 | //! parameter 1/2*sigma^2 |
| 685 | double sig2; |
| 686 | //! access |
| 687 | vec μ |
| 688 | public: |
| 689 | //! Constructor |
| 690 | mlognorm ( ) : eno (), mu(eno._mu()) {ep=&eno;}; |
| 691 | //! Set value of \c k |
| 692 | void set_parameters ( int size, double k) { |
| 693 | sig2 = 0.5*log(k*k+1); |
| 694 | eno.set_parameters(zeros(size),2*sig2*eye(size)); |
| 695 | |
| 696 | dimc = size; |
| 697 | }; |
| 698 | |
| 699 | void condition ( const vec &val ) { |
| 700 | mu=log(val)-sig2;//elem_mult ( refl,pow ( val,l ) ); |
| 701 | }; |
| 702 | }; |
| 703 | |
| 704 | /*! inverse Wishart density |
| 705 | |
| 706 | */ |
| 707 | class iW : public epdf{ |
| 708 | public: |
| 709 | vec sample(){} |
| 710 | }; |
| 711 | |