ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rmvlogistic.cpp
Go to the documentation of this file.
1 #include "statsLib.h"
2 
15 dvector rmvlogistic(const dvector& p, const double& tau2, const int& seed)
16 {
17  int a=p.indexmin();
18  int A=p.indexmax();
19  random_number_generator rng(seed);
20  dvector epsilon(a,A);
21  epsilon.fill_randn(rng);
22  dvector x = log(p)+tau2*epsilon;
23  x -= mean(x);
24  return exp(x)/sum(exp(x));
25 }
#define x
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
dvector rmvlogistic(const dvector &p, const double &tau2, const int &seed)
Definition: rmvlogistic.cpp:15
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
double mean(const dvector &vec)
Returns computed mean of vec.
Definition: cranfill.cpp:43
void fill_randn(long int &n)
Fill vector with random numbers.
Definition: ranfill.cpp:231
Description not yet available.
Definition: fvar.hpp:7951
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
Library of statistic functions.
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13