Function Repository Resource:

# RandomSparseSPDMatrixProbNum

Create a random sparse symmetric positive definite matrix using the Python package ProbNum

Contributed by: Igor Bakshee
 ResourceFunction["RandomSparseSPDMatrixProbNum"][n] creates an n⨯n random sparse symmetric positive definite matrix. ResourceFunction["RandomSparseSPDMatrixProbNum"][session,…] uses the specified running ExternalSessionObject.

## Details and Options

ResourceFunction["RandomSparseSPDMatrixProbNum"] constructs a random matrix from its Cholesky factor in which the diagonal is set to one and all other nonzero entries of the lower triangle are sampled from a uniform distribution with bounds {min,max}.
ResourceFunction["RandomSparseSPDMatrixProbNum"] returns a SparseArray object, a Failure object or \$Failed.
The following options can be given:
 "CholeskyFactorDensity" 0.1 density of the off-diagonal entries of the Cholesky factor “CholeskyFactorRange" {0.1,1.} the min and max values of the off-diagonal elements of the Cholesky factor RandomSeeding Automatic seeding of the pseudorandom generator
The value of "CholeskyFactorDensity" must be between 0 and 1 where 1 represents a dense matrix.
RandomSeeding can be an integer, None, Automatic or a numpy object generator, constructed with the resource function PythonObject.
With , ResourceFunction["RandomSparseSPDMatrixProbNum"] reseeds the random number generator every time the function is called.
ResourceFunction["RandomSparseSPDMatrixProbNum"] is essentially a shortcut to creating a random matrix in Python with the resource function ProbNumObject. It can be used when the current Wolfram Language session does not need access to the underlying Python object.

## Examples

### Basic Examples (3)

Construct a random symmetric positive definite matrix:

 In[1]:=
 Out[1]=

Show the matrix:

 In[2]:=
 Out[2]=

Verify that the matrix is symmetric and positive definite:

 In[3]:=
 Out[3]=

### Scope (2)

Construct a matrix:

 In[4]:=
 Out[4]=

Use a the specified Python session:

 In[5]:=
 Out[5]=
 In[6]:=
 Out[6]=

Close the session:

 In[7]:=

### Options (4)

#### CholeskyFactorDensity (1)

Use the option "CholeskyFactorDensity" to construct a dense matrix:

 In[8]:=
 Out[8]=
 In[9]:=
 Out[9]=

#### CholeskyFactorRange (1)

Create a matrix with larger numerical values using the "CholeskyFactorRange" option:

 In[10]:=
 Out[10]=
 In[11]:=
 Out[11]=

#### RandomSeeding (2)

Ensure reproducibility of the results:

 In[12]:=
 Out[12]=
 In[13]:=
 Out[13]=
 In[14]:=
 Out[14]=

Use the specified random number generator from the Python package numpy for seeding:

 In[15]:=
 Out[15]=
 In[16]:=
 Out[16]=
 In[17]:=
 Out[17]=
 In[18]:=

### Properties and Relations (2)

A random sparse symmetric positive definite matrix can be constructed with the resource function ProbNumObject:

 In[19]:=
 Out[19]=
 In[20]:=
 Out[20]=
 In[21]:=
 Out[21]=
 In[22]:=
 Out[22]=

Construct the same matrix with RandomSparseSPDMatrixProbNum:

 In[23]:=
 Out[23]=
 In[24]:=
 Out[24]=

## Version History

• 1.0.0 – 26 April 2022