Querying Results

#### Next topic

Computational Performance

# Defining Custom Models¶

## Overview¶

CurveExpert allows you to define your own nonlinear regression models; all you have to do is type in the equation. When you choose Define User Model from the Apply Fit menu, you will be presented with a dialog in which you can type or choose your model. Type your model into the edit field provided, or choose a model from the scrolling list. You may use operators and functions in your model that are defined at the end of this help page. Parameters should start at letter ‘a’ and continue sequentially. CurveExpert allows you to use up to 19 parameters, lettered a..s. All arithmetic operations are valid, as well as the symbol ^ to raise a number to a power. Here is an example of what you could enter in the Define User Model dialog box:

`a\*x\*log(b+x)+c^x`

Note that there is no need to enter the ‘y=’ before the function – only the right hand side of the model is entered.

Logical operators are also supported in your user-defined regression models. The operators that are less than (<), greater than (>), less than or equal to (<=), or greater than or equal to (>=). Each of these expressions evaluate to one if the expression is TRUE, or zero if the operation is FALSE. In this way, you can implement logical expression into your model. For example, if you would like to construct a model of two separate lines to where one line is applicable to the region of x<=5, and one line is applicable to x>5, then you might construct the following four-parameter model:

`(a+b\*x)\*(x<=5)+(c+d\*x)\*(x>5)`

These logical operators can be combined in any way to create your user defined model.

See :ref`custom-model-ref` for a complete list of the supported arithmetic and logical operators.

## User Model Dialog¶

A picture of the User Model dialog is shown below, with a description of the controls/operations following:

### User Model Control Buttons¶

• OK: Press OK to use the model that you have entered to fit the data set. The nonlinear regression calculation will begin. If there is a syntax error with your model, you will be notified at this time.
• Cancel: Press Cancel to abort this operation and return to the main window.
• Help: Press Help to learn how to apply custom regression models.

### Model Edit Field¶

Type your custom regression model into this field, using a...s for the model parameters. Parameters should start at letter ‘a’ and continue sequentially. CurveExpert allows you to use up to 19 parameters, lettered a..s. All arithmetic operations are valid, as well as the symbol ^ to raise a number to a power. Note that there is no need to enter the ‘y=’ before the function – only the right hand side of the model is entered. Also, you may edit the text in this box at any time, even after you have selected a model from the Model List.

The normal cut, copy, and paste keys can be used in this edit field; i.e., Ctrl+X for cut, Ctrl+C for copy, and Ctrl+V for paste.

### Model List¶

User models that have been saved will be listed in this box. Scroll up or down to see them all. Selecting an item from this box will simply copy its formula to the Model Edit Field so that you can either click OK to calculate that model, or modify it as necessary. Double-clicking a model in this list will select that model for a regression immediately.

Clicking on this button will add the model that is in the Model Edit Field to the Model List. This operation permanently saves a model that you have typed in. You will be asked what to call the model so that a name (not a formula) will be added to the list.

### Remove Model¶

Clicking on this button will remove the highlighted model from the Model List permanently. A dialog will ask you to verify this operation.

## Custom Model Reference¶

### Operators¶

The following operators are supported by CurveExpert to be used in your custom regression model: * + addition * - subtraction * - unary minus (negation) * * multiplication * / division * ^ power * < less than * > greater than * <= less than or equal to * >= greater than or equal to * != not equal * == equal

### Special Variables¶

The following special variables are supported by CurveExpert may be used in your custom regression model: * pi the constant 3.14159..... * avgx average of the x column * avgy average of the y column * stdx standard deviation of the x column * stdy standard deviation of the y column * minx minimum of the x column * miny minimum of the y column * maxx maximum of the x column * maxy maximum of the y column

### Functions¶

The following functions are supported by CurveExpert to be used in your custom regression model:

• abs absolute value
• fact factorial
• sqrt square root
• exp exponential
• log natural logarithm
• log10 base-10 logarithm
• sin sine
• cos cosine
• tan tangent
• asin arcsine
• acos arccosine atan
• arctangent sinh
• hyperbolic sine
• cosh hyperbolic cosine
• tanh hyperbolic tangent
• ceil first integer greater than value
• floor first integer less than value
• j0 Bessel function of the first kind, 0th order
• j1 Bessel function of the first kind, 1st order
• y0 Bessel function of the second kind, 0th order
• y1 Bessel function of the second kind, 1st order