ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
Functions

functions useful for simulation model in admb More...

#include "qfclib.h"

Go to the source code of this file.

Functions

bool doubleEqual (double nVal1, double nVal2, int nPrecision)
 determine if two double values are equal within some precision
dmatrix findValFromFile (adstring filename, adstring varName, int numVals)
 find the number of values(numVals) for one specific variable(varName) from an admb output file
dvector matrix2vector (const dmatrix &input, int byrow=1)
 convert the matrix as a vector eithter by row=1(default) or by column=0,
dvar_vector matrix2vector (const dvar_matrix &input, int byrow=1)
 convert the matrix as a vector eithter by row=1(default) or by column=0, overloading function
df1b2vector matrix2vector (const df1b2matrix &input, int byrow=1)
 convert the matrix as a vector eithter by row=1(default) or by column=0, overloading function
int numRows4VarFromFile (adstring filename, adstring varName)
 get how many rows for one specific variable(varName) in admb output file(filename)
double rbeta (double alpha, double beta, random_number_generator &rng)
 generate random beta(alpha, beta) number,
dvector rdirichlet (const dvector &shape, random_number_generator &rng)
 generate random dirichlet number
double rgamma (double alpha, random_number_generator &rng)
 generate random gamma number, pseudo code see http://en.wikipedia.org/wiki/Gamma_distribution , Gamma(alpha, belta)=x^(alpha-1)*belta^alpha*exp(-belta*x)/gamma(alpha)
double rgamma (double alpha, double beta, random_number_generator &rng)
 generate random gamma number, mean is alpha/belta, variance is alpha/(belta^2)
double rlnorm (double mu, double sigma, random_number_generator &rng)
 generate one random lognormal number LN(mu,sigma)
double rnorm (double mu, double sigma, random_number_generator &rng)
 generate one random normal number N(mu,sigma)
double runif (double low, double upper, random_number_generator &rng)
 generate one random uniform from (low,upper)
ivector sample (const dvector &source, int nSample, int withReplace, const random_number_generator &rng)
 generate a random sample index(size is nSample) based on the input samples(source) with or without replacement
dvector unique (const dvector &in)
 find the unique values from input vector and only return the unique (by remove the duplicate) values in ascending order
dmatrix vector2matrix (dvector &input, int nrow, int ncol, int byrow=1)
 convert the Vector as a Matrix eithter by row=1(default) or by column=0,
df1b2matrix vector2matrix (df1b2vector &input, int nrow, int ncol, int byrow=1)
 convert the Vector as a Matrix eithter by row=1(default) or by column=0, overloading function
dvar_matrix vector2matrix (const dvar_vector &input, int nrow, int ncol, int byrow=1)
 convert the Vector as a Matrix eithter by row=1(default) or by column=0, overloading function

Detailed Description

functions useful for simulation model in admb

Date:
7/28/2011
Author:
Weihai Liu

Following user defined functions are more useful for doing simulation model in admb, the easy way to use these functions is with your tpl file under the GLOBALS_SECTION , add a line on top as #include "qfclib.h", there is a testfunction.tpl file within this folder show how to use these functions.

================ brief list for usage ============================

  1. return some values for the specific variable name in admb ouput file, such as find the parameter value and its std value from .std file, use findValFromFile("test.std","linf",2), see findValFromFile()
  2. doing random sampling with or without replacement, see sample()
  3. remove the duplicate values from a vector, see unique()
  4. several random number generator, runif(), rnorm(), rgamma(), rdirichlet()
  5. round your matrix, vector, sclar to some specific decimals for display in report_section, such as round(dmatrix,4), see round()
  6. convert vector to matrix by row or by column or its reverse form, see matrix2vector(), vector2matrix()
    =============================================================

found any bug , contact Weihai Liu at liuwe.nosp@m.ih@m.nosp@m.su.ed.nosp@m.u
Quantitative Fisheries Center(QFC), Michigan State University

Definition in file qfc_sim.cpp.