ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Functions

(Last Changed on August 05, 2016 for git-revision 4e745c3fbad754bf4e3e0f177718316ae86def06.)

functions useful for simulation model in admb More...

#include "qfclib.h"

Go to the source code of this file.

Namespaces

 qfclib
 

Functions

bool doubleEqual (double nVal1, double nVal2, int nPrecision)
 determine if two double values are equal within some precision More...
 
dmatrix findValFromFile (adstring filename, adstring varName, int numVals)
 find the number of values(numVals) for one specific variable(varName) from an admb output file More...
 
dvector matrix2vector (const dmatrix &input, int byrow=1)
 convert the matrix as a vector eithter by row=1(default) or by column=0, More...
 
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 More...
 
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 More...
 
int numRows4VarFromFile (adstring filename, adstring varName)
 get how many rows for one specific variable(varName) in admb output file(filename) More...
 
double rbeta (double alpha, double beta, random_number_generator &rng)
 generate random beta(alpha, beta) number, More...
 
dvector rdirichlet (const dvector &shape, random_number_generator &rng)
 generate random dirichlet number More...
 
double qfclib::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) More...
 
double rgamma (double alpha, random_number_generator &rng)
 Copyright (c) 2016 ADMB Foundation. More...
 
double rgamma (double alpha, double beta, random_number_generator &rng)
 generate random gamma number, mean is alpha/belta, variance is alpha/(belta^2) More...
 
double rlnorm (double mu, double sigma, random_number_generator &rng)
 generate one random lognormal number LN(mu,sigma) More...
 
double rnorm (double mu, double sigma, random_number_generator &rng)
 generate one random normal number N(mu,sigma) More...
 
double runif (double low, double upper, random_number_generator &rng)
 generate one random uniform from (low,upper) More...
 
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 More...
 
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 More...
 
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, More...
 
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 More...
 
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 More...
 

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.