EasyFit – Easily Fit Distributions to Your Data!
EasyFit Help HomeLearn More About EasyFit

VBA Functions

EasyFitXL provides a large number of functions which can be used in Excel VBA programs.

Getting Started

Before you can use the functions of EasyFitXL in your VBA project, you should add a reference to the EasyFitXL type library. You only need to do this once for each workbook or XLA project. The type library contains the list of functions provided by EasyFitXL. Once a reference to the type library is added, these functions can be called from your VBA code.

Manually Adding a Reference

To add a reference to the type library, launch the integrated Excel Visual Basic Editor (press Alt-F11 in Excel), and choose Tools|References from the main menu. In the References dialog that appears, locate and check the following item: EasyFitXL 1.0 Type Library (you can press the E key to quickly jump to this item). Click OK to return to the VBE.

Automatically Adding a Reference

If you use Excel 2000, 2002, or 2003, and find it inconvenient to manually add a reference each time you start a new project, you can have this process automated. The EasyFit setup application automatically installs an additional add-in EasyFitXL (VBA) which can be enabled/disabled in the Add-Ins window. If this add-in is enabled, it attempts to add a reference to the EasyFitXL type library for each new workbook you create in Excel. To disable this feature, choose Tools|Add-Ins from the main menu of Excel, and uncheck the corresponding check box.

Note: The default macro security settings prevent add-ins from automatically adding references. To change the security settings, select Tools|Macro|Security from the main menu of Excel, open the Trusted Sources tab, and check the Trust Access to Visual Basic Project check box.

The macro security settings are designed for protecting your system from malicious software, and it might be undesirable to disable this protection.

Using the Template

An alternative way of adding a reference to the EasyFitXL type library is using the Excel template (XLT) file installed with EasyFitXL. When a new workbook is created based on a template file, it inherits all the properties of that file, including the list of type library references. The EasyFitXL template file already contains a reference to the EasyFitXL type library, so if you create a workbook based on this template, your new workbook will contain the necessary reference, and you will not need to add it manually.

To display the templates available on your computer:

  • Excel 2000: select File|New from the main menu;
  • Excel 2002: select File|New from the main menu, then choose General Templates from the New Workbook task pane;
  • Excel 2003: select File|New from the main menu, then choose On My Computer from the New Workbook task pane.

In the window that appears, select EasyFitXL (VBA), and click OK. Excel will create a new workbook which contains a reference to the EasyFitXL type library.

VBA Functions

The following table lists the worksheet functions supported by EasyFitXL:

Description
Function Name
Arguments
Examples
Distribution Functions
Probability Density
Function
DistributionPdf x,parameters NormalPdf(1.5,1,0)
Cumulative Distribution
Function
DistributionCdf x,parameters NormalCdf(1.5,1,0)
Survival Function DistributionSurv x,parameters NormalSurv(1.5,1,0)
Hazard Function DistributionHaz x,parameters NormalHaz(1.5,1,0)
Cumulative Hazard
Function
DistributionCumHaz x,parameters NormalCumHaz(1.5,1,0)
Inverse CDF
(Quantile Function)
DistributionInv P,parameters NormalInv(0.5,1,0)
Random Number Generation
Random Numbers DistributionRand parameters NormalRand(1,0)
Distribution Statistics
Mode DistributionMode parameters NormalMode(1,0)
Mean DistributionMean parameters NormalMean(1,0)
Variance DistributionVar parameters NormalVar(1,0)
Standard Deviation DistributionStdev parameters NormalStdev(1,0)
Skewness DistributionSkew parameters NormalSkew(1,0)
(Excess) Kurtosis DistributionKurt parameters NormalKurt(1,0)

To obtain the function name and the argument list for a particular distribution:

  • replace "distribution" with the specific distribution code name;
  • replace "parameters" with the actual list of distribution parameters (comma-separated); note that the parameters should be specified in the same order as described in this manual (see continuous and discrete distributions);
  • replace "x" and "P" with the function-specific argument values.

Some of the functions listed above are not available for some specific distributions. For instance, the Hazard Function and the Inverse CDF are only available for continuous distributions. Please refer to the documentation on particular distributions for information on which functions are supported.

To view the full list of functions available in EasyFitXL, open the Object Browser (View|Object Browser), and select EasyFitXL from the drop-down list. To get help on a particular function, right click on a function, and select Help.

Randomize

The Randomize procedure allows to initialize the random number generator used in EasyFitXL:

Sub Randomize([seed as Long])

Setting the optional seed parameter to a positive integer (1, 2, ...) allows to produce the same sequence of random numbers each time you run the application, which can be useful for "replaying" the simulation. Each positive integer corresponds to a specific "stream" or sequence of random numbers. To produce a different sequence each time your application is executed, set seed to zero, or omit this parameter.

Note that the Randomize function is also available in the standard VBA (Math) library, so you should use the prefix EasyFitXL to avoid ambiguity, for example:

EasyFitXL.Randomize(1)

See also:

Copyright © MathWave Technologies
www.mathwave.com