 # pwSetOptimizationWeights

```
pwSetOptimizationWeights(formula)

Applies the given formula to all current optimization weights
of the currently combined couples used for fitting.

```

## Description

``` A weight is usually 1/std, where std is the standard deviation
of the current data point.

A weighted residual is given as

w * (yModel - yMeasurement)

During optimization, the sum over squared weighted residuals is minimized.
The displayed chi-square value is the sum over all squared residuals:

chi^2 = sum((w * (yModel - yMeas))^2)

If constraints are used, the optimized chi^2 value may be different
in order to consider the constraints.

Available variables in the formula:

wCurrent value of the weight of a single data point
wArrayArray of weights for the current observable
yMeasCurrent value of the data point
yMeasArrayArray of data point values for the current observable

Internally, the following line is executed:

w = eval(formula)

for each weight, i.e. all data points.

When couples are combined, the weights are set
to 1/(standard deviation) of each data point (either given
by an analytic error model, estimated by PottersWheel, or
given by the user explicitely in the data file).

Applying this function does not affect the original data and
original standard deviation. By calling pwCombine, all changes
are lost.

```

## Examples

``` pwSetOptimizationWeights('w')
Nothing is changed.

pwSetOptimizationWeights('sqrt(w)')
Sets the weights to their square root.
If applied after combining couples,
this corresponds to fitting residuals
(yModel - yMeasurement)/(sqrt(std))
(yModel - yMeasurement)/std.

pwSetOptimizationWeights(1)
Sets all weights to one:
(yModel - yMeasurement)

pwSetOptimizationWeights(0.1)
Sets all weights to one over 10:
(yModel - yMeasurement)/10

```