# restrshapeExact

restrshapeExact computes constrained Gamma (shape) matrix with exact constraints.

## Syntax

• GAMc=restrshapeExact(k, v, shw, shb)example
• GAMc=restrshapeExact(k, v, shw, shb, verLess2016b)example

## Description

The purpose is to generate a constrained shape matrix in such a way that the maximum ratio between the largest/smallest element of each column is equal to shw and the maximum ratio between the largest/smallest element of each row is equal to shb. Finally the product of the element of each column is equal to 1.

 GAMc =restrshapeExact(k, v, shw, shb) restrshapeExact with all the default options.

 GAMc =restrshapeExact(k, v, shw, shb, verLess2016b) Generate 100 replicates of a shape matrix.

## Examples

expand all

### restrshapeExact with all the default options.

two groups and 8 variables

k=2;
v=8;
shb=20;
shw=100;
Sh=restrshapeExact(k, v, shw, shb, 2);
assert(abs(max(max(Sh,[],1)./min(Sh,[],1))-shw)<0.01)
empshb=max(max(Sh,[],2)./min(Sh,[],2));
assert(abs(empshb-shb)<0.1)

### Generate 100 replicates of a shape matrix.

shb=1.5;
shw=4;
v=5;
k=20;
for j=1:100
disp(j)
Sh=restrshapeExact(v,k, shw, shb, 2);
assert(abs(max(max(Sh,[],1)./min(Sh,[],1))-shw)<0.01)
empshb=max(max(Sh,[],2)./min(Sh,[],2));
assert(abs(empshb-shb)<0.1)
end

## Input Arguments

### k — number of groups (components). Scalar.

Desired number of groups.

Data Types: double

### v — number of dimensions (variables). Scalar.

Desired number of variables.

Data Types: double

### shw — within groups shape constraint. Scalar greater or equal 1.

Constraint to impose inside each group. For example, if shw is 3 the maximum ratio between the largest/smallest of each column of output matrix GAMc will be equal to 3.

Data Types: double

### shb — across groups shape constraint. Scalar greater or equal 1.

Constraint to impose among groups. For example, if shb is 5 the maximum ratio between the largest/smallest of each row of matrix GAMc will be equal to 5. Note that shb must be smaller or equal than shw.

Data Types: double

### verLess2016b — is a boolean which is true if current version is less than 2016b. If this argument is omitted routine automatically checks the MATLAB version.

Example: true 

Data Types: double

## Output Arguments

### GAMc —In column j the elements on the main diagonal of shape matrix $\Gamma_j$, $j=1, 2, \ldots, k$. constrained shape matrix. Matrix of size v-by-k

The elements of GAMc satisfy the following constraints:

1) the product of the elements of each column is equal to 1;.

2) The maximum ratio among the largest element divided by the smallest 3) element of each column is equal to shw;

4) The maximum ratio among the largest element divided by the smallest element of each row is equal to shb. The tolerance of the procedure is 0.01.

5) All the elements of GAMc are strictly positive.