# Purity

### Purpose

Calculation of pure variables.

### Synopsis

- [purint,purspec] = purity(data,ncomp,options);
- [model] = purity(data,ncomp);
- [purint,purspec] = purity(data,ncomp,model);
- [model] = purity(data,model);
- purity % Launches an Analysis window with purity as the selected method.

### Description

PURITY calculates pure variables and resolves data into ncomp spectra of the pure components `purspec` and their contributions `purint`. For more information about the algorithm see PURITYENGINE. Data can be a matrix with the data or a dataset object.

The output arguments purity_values contains the purity values for all the variables and can be plotted as the "purity spectrum". The argument length_values contains the purity_values multiplied by the length of the variables. This results in a "length spectrum" that is easier to relate to the original data than the purity spectrum.

NOTE: Wavelength values must be in the first "set" of the axisscale.

### Options

options = a structure array with the following fields:

**display**: ['off'|{'on'}] display to command window.

**plot**: ['off'|{'on'}] plotting of result.

**axistype**: {2x1} [char]

**Mode 1**: [{continuous}|'discrete'|'bar']

**Mode 2**: [{continuous}|'discrete'|'bar'] defines plots. If emtpy the values of the (future) DSO field will be used in case they are not defined, the 'continuous' defaults will be used.

**select**: [{[]},[1 2]] if empty, pure rows/columns will be selected from last slab, otherwise, the numbers identify from which slab(s) the pure rows/columns are selected.

**offset**: [3 10] default noise correction factor for the two slabs.

**offset_row2col**: 3 scalar value row2col offset, default is offset(1).

**mode**: ['rows',{'cols'},'row2col'] determines if pure rows, cols are selected. row2col 2 is row-to-column solution.

**algorithm**: 'purityengine' defines algorithm used.

**interactive**: ['on',{'off'}, defines interactivity; 'on', 'cursor','inactivate','reactivate'] 'reactivate', 'cursor', 'inactivate', 'reactivate' are used for higher level calls for interactivity,'off' is used for demos and command mode applications.

**resolve**: ['off'|{'on'}] indicates if the resolved results are required or not.

### Examples

Resolving 4 components in a data set:

[purint,purspec]=purity(data,4)

### Algorithm

The core algorithm is the function `purityengine`.