# Difference between revisions of "Additional libraries"

(→Individual functions with examples) |
(→Individual functions with examples) |
||

Line 98: | Line 98: | ||

'''Download:''' [[media:Apportion.ana|Apportion.ana]]: Aggregates or disaggregates an array of values from one index to another index, where the second index may be larger or smaller. Does not require the indexes to be index multiples of each other. For example, if you map from a 47-element index to a 13-element index, each 3.62 elements of the original map to an element in the destination, so for example, the first 3 items map to the first item, then the fourth item is shared, with 0.62 apportioned to the first element and 0.38 apportioned to the second element. Supports aggregation types <code>'SUM'</code>, <code>'AVERAGE'</code>, <code>'MIN'</code> and <code>'MAX'</code>. Contributed by Paul Sanford of EPRI. | '''Download:''' [[media:Apportion.ana|Apportion.ana]]: Aggregates or disaggregates an array of values from one index to another index, where the second index may be larger or smaller. Does not require the indexes to be index multiples of each other. For example, if you map from a 47-element index to a 13-element index, each 3.62 elements of the original map to an element in the destination, so for example, the first 3 items map to the first item, then the fourth item is shared, with 0.62 apportioned to the first element and 0.38 apportioned to the second element. Supports aggregation types <code>'SUM'</code>, <code>'AVERAGE'</code>, <code>'MIN'</code> and <code>'MAX'</code>. Contributed by Paul Sanford of EPRI. | ||

− | '''Download: ''' [[media:Sequential dispatch library.ana|Sequential dispatch library.ana]] : | + | '''Download: ''' [[media:Sequential dispatch library.ana|Sequential dispatch library.ana]] : The function '''SequentialDispatch''' generalizes the [[Dispatch]] function by adding a time-like index to carry over unsatisfied demand or unallocated capacity. [[media:Sequential dispatch test.ana|Sequential dispatch test.ana]] is an example of its use. |

==See Also== | ==See Also== |

## Revision as of 17:35, 11 January 2020

## Contents

- 1 Large Sample Library
- 2 The Sensitivity Analysis Library
- 3 Model Documentation Library
- 4 Units Conversion Library
- 5 Greatest Common Divisor functions
- 6 DB Conversion Library
- 7 Spreadsheet Helper Library
- 8 Data Standardization Library
- 9 Additional probability distributions
- 10 Individual functions with examples
- 11 See Also

This page describes a set of useful Analytica function libraries. These are *additional* to the Standard libraries that are automatically installed when you install Analytica. If you want to use any of these additional libraries, click on its link and it will download onto your computer. Depending on your download settings, it may automatically open it in Analytica. Either way, you should save it into a directory so that you can add it into your models. It's usually most convenient to save it with your Standard libraries in directory

`c: Lumina/Analytica 4.6/Libraries`

You can then easily add it into your models using the standard menu option **Add Library...** from the File menu.

See User-defined Functions and Libraries to build your own functions and libraries.

### Large Sample Library

**Download:** Large sample library v10.ana

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

**Prerequisites:** Analytica 5.0 or later. The Domain acts as self index legacy preference must be OFF. You must be using ClearType text (not the very old non-clearType legacy setting).

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

These functions convert between different units -- for example, from feet to kilometers, or from Btu (British thermal units) to gigajoules of energy. They relieve you from having to look up conversion factors. They also make your 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.

You can use the **Conversion example** section to enter a quantity, select its type (dimensions) and units, and convert it to another unit of that type.

#### Library functions

**Units_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).
The units parameters text values must match an abbreviation, synonym, or full name (case insensitive) in the Units data 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.

**Units_conversion**(x, oldUnits, newUnits) returns the value of quantity x converted from oldUnits to newUnits. This works for units like temperature, where simple factors don't work.

**Units_real_dollars**(yr, baseYr) returns a multiplication factor used to convert nominal dollars in year yr to real (also known as constant) dollars using baseYr as the base year. If you omit baseYr, it uses the "Standard base year for inflation" which you can set in the Units Conversion Library user interface. It uses consumer price index data provided by the US Energy Information Administration from 1949 to 2017 with projections up to 2040. It gives an error if yr or baseYr are outside that range.

The **Units_table** contains the list of units, with abbreviation, full-name, and synonyms, type (dimensions) and conversion factors to the base unit for each type. For example, the base unit for 'Energy' is Joule. The conversion factor for gigajoule (GJ) is 10^9. You can add your own units. Be careful to select the correct type (dimensions).

### 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

Lets you embed data obtained from a database into the Analytica model. This breaks the need to use it with an external database, so -- for example -- you can send to someone (e.g. Lumina tech support) who does not have access to the database or has an edition of Analytica (e.g. Professional) that doesn't support database access.

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. This breaks the connection to the external database. So, of course, the model will no longer be able to get new or extended data from the 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 definitions. Do not try to use it if the calls to these functions are embedded within larger expressions or in User-Defined Functions.

* 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.

### Spreadsheet Helper Library

**Download: ** Spreadsheet Helper lib.ana

Includes functions that return the list of worksheet names and the Excel filename of the workbook. It also contains a SpreadsheetOpenEx function that can be used in place of SpreadsheetOpen, but which remembers the filename selected by the user so the next time they don't have to select the file again.

### Data Standardization Library

**Download: ** Data Standardization Library.ana

Imported data is often inconsistent. This library allows you to 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.

## Additional probability distributions

### Laplacian distribution

**Download: ** Laplacian distribution library.ana

**Description: ** The Laplacian distribution (or Laplace distribution) is a continuous, unbounded distribution that is essentially a double-sided Exponential distribution with a «mean» parameter. The library contains the distribution function, and the analytica functions for density, cumulative density and inverse cumulative density (the quantile function).

## Individual functions with examples

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

**Download:** Apportion.ana: Aggregates or disaggregates an array of values from one index to another index, where the second index may be larger or smaller. Does not require the indexes to be index multiples of each other. For example, if you map from a 47-element index to a 13-element index, each 3.62 elements of the original map to an element in the destination, so for example, the first 3 items map to the first item, then the fourth item is shared, with 0.62 apportioned to the first element and 0.38 apportioned to the second element. Supports aggregation types `'SUM'`

, `'AVERAGE'`

, `'MIN'`

and `'MAX'`

. Contributed by Paul Sanford of EPRI.

**Download: ** Sequential dispatch library.ana : The function **SequentialDispatch** generalizes the Dispatch function by adding a time-like index to carry over unsatisfied demand or unallocated capacity. Sequential dispatch test.ana is an example of its use.

## See Also

- Standard libraries: Installed with Analytica
- User Libraries: How to create your own Libraries
- Example Models
- Large Sample Library: User Guide
- Modules and Libraries
- Filed modules and libraries
- User-defined Functions and Libraries
- Example Models and Libraries
- Financial library functions
- The Sensitivity Analysis Library
- Distribution Densities Library
- Linked list library
- Base Conversion Function Library
- Performance Profiler library
- List of libraries

Enable comment auto-refresher