Skip to main content

Eigenvalue unfolding and spectral observable computation

Project description

Table of Contents

Introduction

A python library for investigating some of the basic / classical elements of Random Matrix Theory, including eigenvalue unfolding and computation and plotting of spectral observables.

Motivation

TODO.

Notes on Development

This libary is still undergoing major re-writes and development, and should be considered in pre-alpha at this point. Feel free to post issues or ask questions relating to the code, but keep in mind any bugs and/or issues are very likely to change in the near future.

Installation

As always, using a virtual environment is recommended for proper use. However, you should be okay doing a global pip install empyricalRMT to try out the library.

Using venv (recommended)

Navigate to the project that you wish to use empyricalRMT in.

cd MyProject

Create and active the virtual environment. Replace "env" with whatever name you prefer.

python -m venv env && source env/bin/activate

pip

pip install empyricalRMT

Note that this will install the library "globally" if you haven't activated a virtual environment of some kind.

From source / repository

git clone https://github.com/stfxecutables/empyricalRMT
cd empyricalRMT
pip install -e .

Windows

The above should still all work on Windows, although you may have to follow modified instructions for setting up the venv.

If you run into issues specific to this library that you think might be Windows-related, please do report them, but keep in mind I currently can only test on Windows via virtual machine :(

Basic Usage

import empyricalRMT.observables.unfold as unfold
import empyricalRMT.plot as plot

from empyricalRMT.observables.levelvariance import level_number_variance
from empyricalRMT.observables.rigidty import spectralRigidity
from empyricalRMT.construct import generateGOEMatrix, generate_eigs

# generate a new matrix from the Gaussian Orthogonal Ensemble and extract
# its eigenvalues
eigs = generate_eigs(matsize=1000, kind="goe")
# eigs = generate_eigs(matsize=1000, kind="gue")
# eigs = generate_eigs(matsize=1000, kind="poisson")

# plot the eigenvalue distribution to confirm Wigner's Semicircle law
plot.rawEigDist(eigs, bins=100, title="Wigner Semicircle", block=True)

# plot the eigenvalue step function
plot.stepFunction(eigs, trim=False, block=True)

# plot the normalized spacings to inspect the Nearest Neighbors Spacing
# Distribution (NNSD) and compare it to those predicted by classical RMT
plot.spacings(eigs=eigs, kind="goe")

# unfold the spectrum with a polynomial fit
unfolded = unfold.polynomial(eigs, degree=11)

# Compute the spectral rigidity of the resultant unfolding
L, delta3 = spectralRigidity(unfolded, eigs, c_iters=200, L_grid_size=100, min_L=0.5, max_L=25)
# Plot the resultant values
df = pd.DataFrame({"L": L, "∆3(L)": delta3})
plot.spectralRigidity(unfolded, df, title="GOE Matrix Spectral Rigidity", mode="block")

# Compute the number level variance
L, sigma_sq = level_number_variance(eigs, unfolded, c_iters=1000, L_grid_size=100, min_L=0.5, max_L=20)
# Plot the resultant values
df = pd.DataFrame({"L": L_grid, "∑²(L)": sigma_sq})
plot.levelNumberVariance(unfolded, df, title=f"{kind.upper()} Matrix", mode="block")

Documentation

Be sure to read the documentation comments in the source code.

API Overview

Eigenvalues

  • .trim()

Trimmed

  • etc.

Development

Installation

Assuming you want your venv virtual environment to be named "env":

git clone https://github.com/stfxecutables/empyricalRMT
cd empyricalRMT
python -m venv env
source env/bin/activate
python -m pip install -r requirements-dev.txt
pip install -e .  # to make editable

Testing

To run all tests, run:

python -m pytest -v

There are a number of pytest marks labelling different testing aspects. Brief descriptions can be found in pytest.ini. However, likely most useful will be running:

python -m pytest -v -m fast

which runs all tests that shouldn't take too long to execute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

empyricalRMT-0.2.dev4.tar.gz (60.9 kB view hashes)

Uploaded Source

Built Distribution

empyricalRMT-0.2.dev4-py3-none-any.whl (72.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page