# Additional libraries

(Up to Analytica Wiki)

## Contents

- 1 Individual functions with examples
- 2 Libraries Not Included with the Analytica Installer
- 3 Libraries included with Analytica
- 3.1 Bayes Function
- 3.2 Complex Numbers
- 3.3 Concatenation
- 3.4 Data Statistics
- 3.5 Distribution Densities
- 3.6 Distribution Variations
- 3.7 Expand Index
- 3.8 Financial Functions
- 3.9 Flat File Library
- 3.10 Garbage Bin
- 3.11 Generalized Regression
- 3.12 Linked Lists
- 3.13 Multivariate Distributions
- 3.14 ODBC Database Functions
- 3.15 Optimization Functions
- 3.16 Performance Profiler

# Individual functions with examples

- Recumulate example.ana : Like Cumulate, but resets to zero at selected points.

# Libraries Not Included with the Analytica Installer

## Large Sample Library

The Large Sample Library is an Analytica library that lets you run a Monte Carlo simulation for large models or a large sample size that might otherwise exhaust computer memory, including virtual memory. It breaks up a large sample into a series of batch samples, each small enough to run in memory. For selected variables, known as the Large Sample Variables or LSVs, it accumulates the batches into a large sample. You can then view the probability distributions for each LSV using the standard methods — confidence bands, PDF, CDF, etc. — with the full precision of the large sample.

See Large Sample Library: User Guide.

## The Sensitivity Analysis Library

The Sensitivity Analysis Library provides functions for analyzing the sensitivity of an output to each cell of each array-valued chance input, and locating those individual scalar inputs that have the greatest impact on the result. See The Sensitivity Analysis Library for documentation on using this library.

The library itself can be downloaded from Sensitivity Analysis Library.ana, and an example model to demonstrate its usage is at Sensitivity Functions Examples.ana.

## Model Documentation Library

**Download: ** Model Documentation Library.ana

**Requires:** Analytica 4.1.0 or later

Some people like to create a concise report on paper that contains all objects in their model along with descriptions or other selected attributes. The "Print Report" feature in Analytica can be used for this purpose, but is not at all concise and ends up placing each object window on a separate page. The *Model Documentation Library* allows you to select a module from your model and produce a result table containing every object within that module with its selected attributes such as title, description, units, definition, or user-defined attributes. This table can then be exported to Excel where you can format it nicely and print it. Thus, you can end up with a very concise report on paper.

To use this library, load your model and then select **File-->Add Module...**. Add the Model Documentation Library.ana module file using Embed. In that module, using the pulldown, select the top-level module for the report. Follow the instructions shown on the diagram. If you make changes to your model later, press the *Update Model Documentation* button to adjust the pulldown content.

## Units Conversion Library

**Download: ** Units conversion library.ana

The functions in this library provide conversions between different units -- for example, from feet to kilometers, or from Btu (British thermal units) to gigajoules of energy. Using this library relieves you from having to look up conversion factors. It also makes the model more transparent by making it clear where you are converting from one units to another -- instead of just embedding conversion constants in the formulas.

Use Conversion_Factor(oldUnits, newUnits) to give a conversion factor between two units. If you omit newUnits, it will assume the standard units for that type (dimensions). When specifying units , you must use a symbol (abbreviation) from the Units table.

If the units are of different dimensions, e.g. energy and power, or if it doesn't recognize the units, it will give an error.

Use Nom_to_real_dollars(yr, baseYr) to convert from nominal dollars for year yr to "real dollars" for specified baseYr. If you omit baseYr, it defaults to the Standard base year, initially 2000.

These conversion factors were provided on October 20, 2007 by Chris Marnay of the Lawrence Berkeley Laboratory, as part of his work on the SEDS project.

## Greatest Common Divisor functions

**Download: ** GCD function library.ana

This library contains two User-Defined Functions for computing the greatest common divisor.

## DB Conversion Library

**Download: ** DB conversion lib.ana

Press a button in this library to transform all the variables defined using DbQuery, DbLabels and DbTable to literal data. Variables and indexes defined using DbQuery or DbLabels are transformed to list definitions, and those defined using DbTable are transformed into edit tables. The transformation has the effect of breaking the connection to the external database.

The library is limited in its scope. It only works when all calls to DbQuery, DbLabels and DbTable occur at the top level of variable nodes. Do not attempt to use it if you have calls to these functions embedded within larger expressions or within User-Defined Functions.

The purpose of this library is to make it possible to send a copy of your model to another person (including to Lumina Tech Support) who does not have access to your external database, or who does not have Analytica Enterprise.

* Use with extreme caution!!*: Make a copy of your original model

*before*adding and executing this module. After running the transformation, be sure to use

**File→Save As...**to save the transformed model under a different filename, so you don't clobber your original model.

## Data Standardization Library

**Download: ** Data Standardization Library.ana

Imported data is often inconsistent. This library allows choose what the "standard" values should be in a column of data. You can then map any non-standard value to one of the standard values. The result is a column of consistent data.

# Libraries included with Analytica

The following libraries are copied to your computer when you install any edition of Analytica (including Trial). You can conveniently add these to a model by selecting **Add Library...** from the **File** menu in Analyica.

## Bayes Function

Functions for a simple application of Bayes' rule to a complete discrete joint array of prior probabilities.

Download: File:Bayes Function.ana

## Complex Numbers

Functions for computing with complex numbers.

Download: File:Complex Library.ana

## Concatenation

Functions for concatenation of arrays. Several ConcatN functions allow N arrays to be concatenated in a single call, as an alternative to calling the built-in Concat function N times in sequence. ConcatRows joins the rows of an array .

Download: File:Concatenation.ana

## Data Statistics

This library is deprecated (obsolete) in Analytica 4.0, but is still included for backward compatibility for models that used these functions in earlier versions of Analytica. Functions allow statistics, such as SDevation, to be applied across indexes other than Run. The built-in statistical functions now allow the running index to be optionally specified.

Download: File:Data Statistics Library.ana

## Distribution Densities

Functions that return the analytic density function for continuous distributions. These densities can be used when using importance sampling, for example. The library is described in detail at Distribution Densities Library.

A new version (after the 4.1.1 release) is now available that includes density functions for all built-in continuous and discrete distributions, as well as for a few other distributions (F-dist, Wishart, Gaussian,...). This version also include cumulative distribution functions and inverse cumulative distribution functions for many distributions. See Distribution Densities Library for more details. To get the newest version, download the library below, then replace the one in your Libraries directory.

Download: Distribution Densities.ana

## Distribution Variations

A variety of alternative parametrizations of built-in univariate distributions, and other common parametric univariate distributions that are simple transformations of built-in distributions.

Download: File:Distribution Variations.ana

## Expand Index

Download: File:Expand Index.ana

## Financial Functions

Includes functions for derivative valuations, bond pricing, etc.

Note: Standard financial functions (equivalent to those found in Excel) are built into Analytica and are found in the built-in Financial Functions library.

Download: File:Financial Library.ana

## Flat File Library

Functions for reading data from a comma-separated flat file format (.CSV) into Analytica arrays.

Download: File:Flat File Library.ana

## Garbage Bin

Provides a garbage bin icon. Instead of deleting nodes, you can drag them to the garbage bin. The "deletion" can then be undone if necessary. Also, if the node you delete has dependents or dependencies, this is immediately evident by the arrows emanating to or from the garbage bin.

To empty the garbage bin, double click on it to open it, select all and delete. Emptying the garbage bin in this fashion is not undoable. You must delete an object (permanently) from the garbage bin before you can reuse its identifier.

Download: File:Garbage Bin.ana

## Generalized Regression

(Requires Analytica Optimizer )

Logistic and Probit regression. These functions are used to fit a function that predicts the probability of an outcome based on a set of continuous independent variables, from a data set where each data point is classified as either 0 or 1.

Download: File:Generalized Regression.ana

## Linked Lists

Download: File:Linked List Library.ana

## Multivariate Distributions

Variout multi-dimensional distributions, and the ability to generated correlated distributions.

Download: File:Multivariate Distributions.ana

## ODBC Database Functions

## Optimization Functions

Provides some elementary optimization functions:

- GoalSeek
- Solve
- Gradient

These are usable even without Analytica Optimizer; however they are based on a rudimentary gradient-descent algorithm and don't have anything near the power of the Frontline solver functions provided by Analytica Optimizer functions.

Download: File:Optimization Functions.ana

## Performance Profiler

(Required Analytica Enterprise)

Used to determine where a model is consuming time and memory resources.

Download: File:Performance Profiler.ana

Enable comment auto-refresher