freealg 0.7.1__tar.gz → 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {freealg-0.7.1 → freealg-0.7.3}/PKG-INFO +1 -1
- {freealg-0.7.1 → freealg-0.7.3}/freealg/__init__.py +1 -1
- freealg-0.7.3/freealg/__version__.py +1 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_algebraic_form/_continuation_algebraic.py +46 -5
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_algebraic_form/algebraic_form.py +3 -1
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/__init__.py +1 -1
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_linalg.py +1 -1
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_support.py +5 -5
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_chiral_block.py +69 -15
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_deformed_marchenko_pastur.py +71 -13
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_deformed_wigner.py +57 -15
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_kesten_mckay.py +1 -1
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_marchenko_pastur.py +1 -1
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_meixner.py +1 -1
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_wachter.py +1 -1
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/_wigner.py +1 -1
- {freealg-0.7.1 → freealg-0.7.3}/freealg.egg-info/PKG-INFO +1 -1
- {freealg-0.7.1 → freealg-0.7.3}/freealg.egg-info/SOURCES.txt +13 -13
- freealg-0.7.1/freealg/__version__.py +0 -1
- {freealg-0.7.1 → freealg-0.7.3}/AUTHORS.txt +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/CHANGELOG.rst +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/LICENSE.txt +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/MANIFEST.in +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/README.rst +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_algebraic_form/__init__.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_algebraic_form/_decompress.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_algebraic_form/_edge.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_algebraic_form/_sheets_util.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_chebyshev.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_damp.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_decompress.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_density_util.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_jacobi.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_pade.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_plot_util.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_sample.py +0 -0
- {freealg-0.7.1/freealg/_freeform → freealg-0.7.3/freealg/_free_form}/_series.py +0 -0
- /freealg-0.7.1/freealg/_freeform/freeform.py → /freealg-0.7.3/freealg/_free_form/free_form.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_geometric_form/__init__.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_geometric_form/_continuation_genus0.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_geometric_form/_continuation_genus1.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_geometric_form/_elliptic_functions.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_geometric_form/_sphere_maps.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_geometric_form/_torus_maps.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_geometric_form/geometric_form.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/_util.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/distributions/__init__.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/visualization/__init__.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/visualization/_glue_util.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg/visualization/_rgb_hsv.py +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg.egg-info/dependency_links.txt +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg.egg-info/not-zip-safe +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg.egg-info/requires.txt +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/freealg.egg-info/top_level.txt +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/pyproject.toml +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/requirements.txt +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/setup.cfg +0 -0
- {freealg-0.7.1 → freealg-0.7.3}/setup.py +0 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# under the terms of the license found in the LICENSE.txt file in the root
|
|
7
7
|
# directory of this source tree.
|
|
8
8
|
|
|
9
|
-
from .
|
|
9
|
+
from ._free_form import FreeForm, eigvalsh, cond, norm, trace, slogdet, supp, \
|
|
10
10
|
sample, kde
|
|
11
11
|
from ._algebraic_form import AlgebraicForm
|
|
12
12
|
from ._geometric_form import GeometricForm
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.7.3"
|
|
@@ -14,10 +14,48 @@
|
|
|
14
14
|
import numpy
|
|
15
15
|
from .._geometric_form._continuation_genus0 import joukowski_z
|
|
16
16
|
|
|
17
|
-
__all__ = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
__all__ = ['sample_z_joukowski', 'filter_z_away_from_cuts', 'powers',
|
|
18
|
+
'fit_polynomial_relation', 'eval_P', 'eval_roots',
|
|
19
|
+
'build_sheets_from_roots']
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# ======================
|
|
23
|
+
# normalize coefficients
|
|
24
|
+
# ======================
|
|
25
|
+
|
|
26
|
+
def _normalize_coefficients(a):
|
|
27
|
+
"""
|
|
28
|
+
Trim rows and columns on the sides (equivalent to factorizing or reducing
|
|
29
|
+
degree) and normalize so that the sum of the first column is one.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
if a.size == 0:
|
|
33
|
+
return a
|
|
34
|
+
|
|
35
|
+
# --- Trim zero rows (top and bottom) ---
|
|
36
|
+
non_zero_rows = numpy.any(a != 0, axis=1)
|
|
37
|
+
if not numpy.any(non_zero_rows):
|
|
38
|
+
return a[:0, :0]
|
|
39
|
+
|
|
40
|
+
first_row = numpy.argmax(non_zero_rows)
|
|
41
|
+
last_row = len(non_zero_rows) - numpy.argmax(non_zero_rows[::-1])
|
|
42
|
+
a = a[first_row:last_row, :]
|
|
43
|
+
|
|
44
|
+
# --- Trim zero columns (left and right) ---
|
|
45
|
+
non_zero_cols = numpy.any(a != 0, axis=0)
|
|
46
|
+
if not numpy.any(non_zero_cols):
|
|
47
|
+
return a[:, :0]
|
|
48
|
+
|
|
49
|
+
first_col = numpy.argmax(non_zero_cols)
|
|
50
|
+
last_col = len(non_zero_cols) - numpy.argmax(non_zero_cols[::-1])
|
|
51
|
+
a = a[:, first_col:last_col]
|
|
52
|
+
|
|
53
|
+
# --- Normalize so first column sums to 1 ---
|
|
54
|
+
col_sum = numpy.sum(a[:, 0])
|
|
55
|
+
if col_sum != 0:
|
|
56
|
+
a = a / col_sum
|
|
57
|
+
|
|
58
|
+
return a
|
|
21
59
|
|
|
22
60
|
|
|
23
61
|
# ==================
|
|
@@ -91,7 +129,7 @@ def powers(x, deg):
|
|
|
91
129
|
# =======================
|
|
92
130
|
|
|
93
131
|
def fit_polynomial_relation(z, m, s, deg_z, ridge_lambda=0.0, weights=None,
|
|
94
|
-
triangular=None):
|
|
132
|
+
triangular=None, normalize=False):
|
|
95
133
|
|
|
96
134
|
z = numpy.asarray(z, dtype=complex).ravel()
|
|
97
135
|
m = numpy.asarray(m, dtype=complex).ravel()
|
|
@@ -167,6 +205,9 @@ def fit_polynomial_relation(z, m, s, deg_z, ridge_lambda=0.0, weights=None,
|
|
|
167
205
|
for k, (i, j) in enumerate(pairs):
|
|
168
206
|
full[i, j] = coef[k]
|
|
169
207
|
|
|
208
|
+
if normalize:
|
|
209
|
+
full = _normalize_coefficients(full)
|
|
210
|
+
|
|
170
211
|
return full
|
|
171
212
|
|
|
172
213
|
|
|
@@ -183,6 +183,7 @@ class AlgebraicForm(object):
|
|
|
183
183
|
y_eps=2e-2,
|
|
184
184
|
x_pad=0.0,
|
|
185
185
|
triangular=None,
|
|
186
|
+
normalize=False,
|
|
186
187
|
verbose=False):
|
|
187
188
|
"""
|
|
188
189
|
Fits polynomial.
|
|
@@ -213,7 +214,8 @@ class AlgebraicForm(object):
|
|
|
213
214
|
m1_fit = self.stieltjes(z_fit)
|
|
214
215
|
a_coeffs = fit_polynomial_relation(z_fit, m1_fit, s=deg_m, deg_z=deg_z,
|
|
215
216
|
ridge_lambda=reg,
|
|
216
|
-
triangular=triangular
|
|
217
|
+
triangular=triangular,
|
|
218
|
+
normalize=normalize)
|
|
217
219
|
|
|
218
220
|
self.a_coeffs = a_coeffs
|
|
219
221
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# under the terms of the license found in the LICENSE.txt file in the root
|
|
7
7
|
# directory of this source tree.
|
|
8
8
|
|
|
9
|
-
from .
|
|
9
|
+
from .free_form import FreeForm
|
|
10
10
|
from ._linalg import eigvalsh, cond, norm, trace, slogdet
|
|
11
11
|
from ._support import supp
|
|
12
12
|
from ._sample import sample
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# =======
|
|
12
12
|
|
|
13
13
|
import numpy
|
|
14
|
-
import numba
|
|
14
|
+
# import numba
|
|
15
15
|
from scipy.stats import gaussian_kde
|
|
16
16
|
|
|
17
17
|
__all__ = ['support_from_density', 'supp']
|
|
@@ -21,10 +21,10 @@ __all__ = ['support_from_density', 'supp']
|
|
|
21
21
|
# support from density
|
|
22
22
|
# ====================
|
|
23
23
|
|
|
24
|
-
@numba.njit(numba.types.UniTuple(numba.types.int64, 2)(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
))
|
|
24
|
+
# @numba.njit(numba.types.UniTuple(numba.types.int64, 2)(
|
|
25
|
+
# numba.types.float64,
|
|
26
|
+
# numba.types.float64[::1]
|
|
27
|
+
# ))
|
|
28
28
|
def support_from_density(dx, density):
|
|
29
29
|
"""
|
|
30
30
|
Estimates the support from a collection of noisy observations of a
|
|
@@ -404,7 +404,7 @@ class ChiralBlock(object):
|
|
|
404
404
|
----------
|
|
405
405
|
|
|
406
406
|
size : int
|
|
407
|
-
|
|
407
|
+
Total size :math:`N = n + m` of the returned matrix.
|
|
408
408
|
|
|
409
409
|
seed : int, default=None
|
|
410
410
|
Seed for random number generator.
|
|
@@ -413,7 +413,24 @@ class ChiralBlock(object):
|
|
|
413
413
|
-------
|
|
414
414
|
|
|
415
415
|
A : numpy.ndarray
|
|
416
|
-
|
|
416
|
+
Symmetric matrix of shape :math:`N \\times N`.
|
|
417
|
+
|
|
418
|
+
Notes
|
|
419
|
+
-----
|
|
420
|
+
|
|
421
|
+
Generate a :math:`(n+m) x (n+m)` matrix
|
|
422
|
+
|
|
423
|
+
.. math::
|
|
424
|
+
|
|
425
|
+
H =
|
|
426
|
+
\\begin{bmatrix}
|
|
427
|
+
\\alpha \\mathbf{I}_n & (1/\\sqrt{m})) \\mathbf{X} \\
|
|
428
|
+
(1/\\sqrt{m})) \\mathbf{X}^{\\intercal} & \\beta \\mathbf{I}_m
|
|
429
|
+
\\end{bmatrix}
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
where :math:`\\mathbf{X}` has i.i.d. :math:`N(0,1)` entries and
|
|
433
|
+
:math:`n/m` approximates :math:`c`.
|
|
417
434
|
|
|
418
435
|
Examples
|
|
419
436
|
--------
|
|
@@ -425,16 +442,53 @@ class ChiralBlock(object):
|
|
|
425
442
|
>>> A = mp.matrix(2000)
|
|
426
443
|
"""
|
|
427
444
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
#
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
445
|
+
N = int(size)
|
|
446
|
+
if N <= 1:
|
|
447
|
+
raise ValueError("size must be an integer >= 2.")
|
|
448
|
+
|
|
449
|
+
# Unpack parameters
|
|
450
|
+
alpha = float(self.alpha)
|
|
451
|
+
beta = float(self.beta)
|
|
452
|
+
c = float(self.c)
|
|
453
|
+
|
|
454
|
+
rng = numpy.random.default_rng(seed)
|
|
455
|
+
|
|
456
|
+
# Choose n,m so that n/m approx c and n+m = N.
|
|
457
|
+
# Solve n = c m and n + m = N -> m = N/(c+1), n = cN/(c+1).
|
|
458
|
+
m = int(round(N / (c + 1.0)))
|
|
459
|
+
m = max(1, min(N - 1, m))
|
|
460
|
+
n = N - m
|
|
461
|
+
|
|
462
|
+
# Optionally refine to get ratio closer to c (cheap local search).
|
|
463
|
+
# This keeps deterministic behavior.
|
|
464
|
+
best_n = n
|
|
465
|
+
best_m = m
|
|
466
|
+
best_err = abs((n / float(m)) - c)
|
|
467
|
+
for dm in (-2, -1, 0, 1, 2):
|
|
468
|
+
mm = m + dm
|
|
469
|
+
if mm <= 0 or mm >= N:
|
|
470
|
+
continue
|
|
471
|
+
nn = N - mm
|
|
472
|
+
err = abs((nn / float(mm)) - c)
|
|
473
|
+
if err < best_err:
|
|
474
|
+
best_err = err
|
|
475
|
+
best_n = nn
|
|
476
|
+
best_m = mm
|
|
477
|
+
n = best_n
|
|
478
|
+
m = best_m
|
|
479
|
+
|
|
480
|
+
# Draw X (n x m) with i.i.d. entries
|
|
481
|
+
X = rng.standard_normal((n, m))
|
|
482
|
+
|
|
483
|
+
# Assemble H
|
|
484
|
+
H = numpy.zeros((N, N), dtype=numpy.float64)
|
|
485
|
+
|
|
486
|
+
H[:n, :n] = alpha * numpy.eye(n, dtype=numpy.float64)
|
|
487
|
+
H[n:, n:] = beta * numpy.eye(m, dtype=numpy.float64)
|
|
488
|
+
|
|
489
|
+
s = 1.0 / numpy.sqrt(float(m))
|
|
490
|
+
B = s * X
|
|
491
|
+
H[:n, n:] = B
|
|
492
|
+
H[n:, :n] = B.T
|
|
493
|
+
|
|
494
|
+
return H
|
|
@@ -70,6 +70,15 @@ class DeformedMarchenkoPastur(object):
|
|
|
70
70
|
Initialization.
|
|
71
71
|
"""
|
|
72
72
|
|
|
73
|
+
if not (0.0 <= w1 <= 1.0):
|
|
74
|
+
raise ValueError("w1 must be in [0, 1].")
|
|
75
|
+
|
|
76
|
+
if c < 0.0:
|
|
77
|
+
raise ValueError("c must be >= 0.")
|
|
78
|
+
|
|
79
|
+
if t1 < 0.0 or t2 < 0.0:
|
|
80
|
+
raise ValueError("t1 and t2 must be >= 0 for a covariance model.")
|
|
81
|
+
|
|
73
82
|
self.t1 = t1
|
|
74
83
|
self.t2 = t2
|
|
75
84
|
self.w1 = w1
|
|
@@ -592,6 +601,24 @@ class DeformedMarchenkoPastur(object):
|
|
|
592
601
|
A : numpy.ndarray
|
|
593
602
|
A matrix of the size :math:`n \\times n`.
|
|
594
603
|
|
|
604
|
+
Notes
|
|
605
|
+
-----
|
|
606
|
+
|
|
607
|
+
Generate an :math:`n x n` sample covariance matrix :math:`\\mathbf{S}`
|
|
608
|
+
whose ESD converges to :math:`H \\boxtimes MP_c`, where
|
|
609
|
+
:math:`H = w_1 \\delta_{t_1} + (1-w_1) \\delta_{t_2}`.
|
|
610
|
+
|
|
611
|
+
Finite :math:`n` construction:
|
|
612
|
+
|
|
613
|
+
* :math:`m` is chosen so that :math:`n/m` approx :math:`c` (when
|
|
614
|
+
:math:`c>0`),
|
|
615
|
+
* :math:`Z` has i.i.d. :math:`N(0,1)`,
|
|
616
|
+
* :math:`\\boldsymbol{\\Sigma}` has eigenvalues :math:`t_1`,
|
|
617
|
+
:math:`t_2` with proportions
|
|
618
|
+
:math:`w_1`, and :math:`1-w_1`,
|
|
619
|
+
* :math:`\\mathbf{S} = (1/m) \\boldsymbol{\\Sigma}^{1/2} \\mathbf{Z}
|
|
620
|
+
\\mathbf{Z}^T \\boldsymbol{\\Sigma}^{1/2}`.
|
|
621
|
+
|
|
595
622
|
Examples
|
|
596
623
|
--------
|
|
597
624
|
|
|
@@ -602,16 +629,47 @@ class DeformedMarchenkoPastur(object):
|
|
|
602
629
|
>>> A = mp.matrix(2000)
|
|
603
630
|
"""
|
|
604
631
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
#
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
632
|
+
n = int(size)
|
|
633
|
+
if n <= 0:
|
|
634
|
+
raise ValueError("size must be a positive integer.")
|
|
635
|
+
|
|
636
|
+
# Unpack parameters
|
|
637
|
+
t1 = float(self.t1)
|
|
638
|
+
t2 = float(self.t2)
|
|
639
|
+
w1 = float(self.w1)
|
|
640
|
+
c = float(self.c)
|
|
641
|
+
|
|
642
|
+
rng = numpy.random.default_rng(seed)
|
|
643
|
+
|
|
644
|
+
# Choose m so that n/m approx c (for c>0). For c=0, return population
|
|
645
|
+
# Sigma.
|
|
646
|
+
if c == 0.0:
|
|
647
|
+
n1 = int(round(w1 * n))
|
|
648
|
+
n1 = max(0, min(n, n1))
|
|
649
|
+
d = numpy.empty(n, dtype=numpy.float64)
|
|
650
|
+
d[:n1] = t1
|
|
651
|
+
d[n1:] = t2
|
|
652
|
+
rng.shuffle(d)
|
|
653
|
+
return numpy.diag(d)
|
|
654
|
+
|
|
655
|
+
# m must be positive integer
|
|
656
|
+
m = int(round(n / c)) if c > 0.0 else n
|
|
657
|
+
m = max(1, m)
|
|
658
|
+
|
|
659
|
+
# Build diagonal Sigma^{1/2} with two atoms
|
|
660
|
+
n1 = int(round(w1 * n))
|
|
661
|
+
n1 = max(0, min(n, n1))
|
|
662
|
+
|
|
663
|
+
s = numpy.empty(n, dtype=numpy.float64)
|
|
664
|
+
s[:n1] = numpy.sqrt(t1)
|
|
665
|
+
s[n1:] = numpy.sqrt(t2)
|
|
666
|
+
rng.shuffle(s)
|
|
667
|
+
|
|
668
|
+
# Draw Z and form X = Sigma^{1/2} Z / sqrt(m)
|
|
669
|
+
Z = rng.standard_normal((n, m))
|
|
670
|
+
X = (s[:, None] * Z) / numpy.sqrt(m)
|
|
671
|
+
|
|
672
|
+
# Sample covariance
|
|
673
|
+
S = X @ X.T
|
|
674
|
+
|
|
675
|
+
return S
|
|
@@ -35,6 +35,9 @@ class DeformedWigner(object):
|
|
|
35
35
|
Initialization.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
|
+
if not (0.0 <= w1 <= 1.0):
|
|
39
|
+
raise ValueError("w1 must be in [0, 1].")
|
|
40
|
+
|
|
38
41
|
self.t1 = t1
|
|
39
42
|
self.t2 = t2
|
|
40
43
|
self.w1 = w1
|
|
@@ -287,26 +290,65 @@ class DeformedWigner(object):
|
|
|
287
290
|
A : numpy.ndarray
|
|
288
291
|
A matrix of the size :math:`n \\times n`.
|
|
289
292
|
|
|
293
|
+
Parameters
|
|
294
|
+
----------
|
|
295
|
+
size : int
|
|
296
|
+
Size n of the matrix.
|
|
297
|
+
|
|
298
|
+
seed : int, default=None
|
|
299
|
+
Seed for random number generator.
|
|
300
|
+
|
|
301
|
+
Returns
|
|
302
|
+
-------
|
|
303
|
+
A : numpy.ndarray
|
|
304
|
+
Symmetric matrix of shape (n, n).
|
|
305
|
+
|
|
306
|
+
Notes
|
|
307
|
+
-----
|
|
308
|
+
|
|
309
|
+
Generate an :math:`n x n` matrix :math:`\\mathbf{A} = \\mathbf{T} +
|
|
310
|
+
\\sigma \\mathbf{W}` whose ESD converges to
|
|
311
|
+
:math:`H \\boxplus SC_{\\sigma^2}`, where
|
|
312
|
+
:math:`H = w_1 \\delta_{t_1} + (1-w_1) \\delta_{t_2}`.
|
|
313
|
+
|
|
290
314
|
Examples
|
|
291
315
|
--------
|
|
292
316
|
|
|
293
317
|
.. code-block::python
|
|
294
318
|
|
|
295
|
-
>>> from freealg.distributions import
|
|
296
|
-
>>> mp =
|
|
319
|
+
>>> from freealg.distributions import DeformedWigner
|
|
320
|
+
>>> mp = DeformedWigner(1/50)
|
|
297
321
|
>>> A = mp.matrix(2000)
|
|
298
322
|
"""
|
|
299
323
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
#
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
#
|
|
311
|
-
|
|
312
|
-
|
|
324
|
+
n = int(size)
|
|
325
|
+
if n <= 0:
|
|
326
|
+
raise ValueError("size must be a positive integer.")
|
|
327
|
+
|
|
328
|
+
# Unpack parameters
|
|
329
|
+
t1 = float(self.t1)
|
|
330
|
+
t2 = float(self.t2)
|
|
331
|
+
w1 = float(self.w1)
|
|
332
|
+
sigma = float(self.sigma)
|
|
333
|
+
|
|
334
|
+
# RNG
|
|
335
|
+
rng = numpy.random.default_rng(seed)
|
|
336
|
+
|
|
337
|
+
# T part
|
|
338
|
+
n1 = int(round(w1 * n))
|
|
339
|
+
n1 = max(0, min(n, n1))
|
|
340
|
+
|
|
341
|
+
d = numpy.empty(n, dtype=numpy.float64)
|
|
342
|
+
d[:n1] = t1
|
|
343
|
+
d[n1:] = t2
|
|
344
|
+
rng.shuffle(d) # randomize positions
|
|
345
|
+
T = numpy.diag(d)
|
|
346
|
+
|
|
347
|
+
# W part: Symmetric Wigner with variance 1/n (up to symmetry)
|
|
348
|
+
G = rng.standard_normal((n, n))
|
|
349
|
+
W = (G + G.T) * (0.5 / numpy.sqrt(n))
|
|
350
|
+
|
|
351
|
+
# Compose
|
|
352
|
+
A = T + sigma * W
|
|
353
|
+
|
|
354
|
+
return A
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import numpy
|
|
15
15
|
from scipy.interpolate import interp1d
|
|
16
|
-
from ..
|
|
16
|
+
from .._free_form._plot_util import plot_density, plot_hilbert, \
|
|
17
17
|
plot_stieltjes, plot_stieltjes_on_disk, plot_samples
|
|
18
18
|
|
|
19
19
|
try:
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import numpy
|
|
15
15
|
from scipy.interpolate import interp1d
|
|
16
|
-
from ..
|
|
16
|
+
from .._free_form._plot_util import plot_density, plot_hilbert, \
|
|
17
17
|
plot_stieltjes, plot_stieltjes_on_disk, plot_samples
|
|
18
18
|
from ..visualization import glue_branches
|
|
19
19
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import numpy
|
|
15
15
|
from scipy.interpolate import interp1d
|
|
16
|
-
from ..
|
|
16
|
+
from .._free_form._plot_util import plot_density, plot_hilbert, \
|
|
17
17
|
plot_stieltjes, plot_stieltjes_on_disk, plot_samples
|
|
18
18
|
|
|
19
19
|
try:
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import numpy
|
|
15
15
|
from scipy.interpolate import interp1d
|
|
16
|
-
from ..
|
|
16
|
+
from .._free_form._plot_util import plot_density, plot_hilbert, \
|
|
17
17
|
plot_stieltjes, plot_stieltjes_on_disk, plot_samples
|
|
18
18
|
|
|
19
19
|
try:
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import numpy
|
|
15
15
|
from scipy.interpolate import interp1d
|
|
16
|
-
from ..
|
|
16
|
+
from .._free_form._plot_util import plot_density, plot_hilbert, \
|
|
17
17
|
plot_stieltjes, plot_stieltjes_on_disk, plot_samples
|
|
18
18
|
|
|
19
19
|
try:
|
|
@@ -22,19 +22,19 @@ freealg/_algebraic_form/_decompress.py
|
|
|
22
22
|
freealg/_algebraic_form/_edge.py
|
|
23
23
|
freealg/_algebraic_form/_sheets_util.py
|
|
24
24
|
freealg/_algebraic_form/algebraic_form.py
|
|
25
|
-
freealg/
|
|
26
|
-
freealg/
|
|
27
|
-
freealg/
|
|
28
|
-
freealg/
|
|
29
|
-
freealg/
|
|
30
|
-
freealg/
|
|
31
|
-
freealg/
|
|
32
|
-
freealg/
|
|
33
|
-
freealg/
|
|
34
|
-
freealg/
|
|
35
|
-
freealg/
|
|
36
|
-
freealg/
|
|
37
|
-
freealg/
|
|
25
|
+
freealg/_free_form/__init__.py
|
|
26
|
+
freealg/_free_form/_chebyshev.py
|
|
27
|
+
freealg/_free_form/_damp.py
|
|
28
|
+
freealg/_free_form/_decompress.py
|
|
29
|
+
freealg/_free_form/_density_util.py
|
|
30
|
+
freealg/_free_form/_jacobi.py
|
|
31
|
+
freealg/_free_form/_linalg.py
|
|
32
|
+
freealg/_free_form/_pade.py
|
|
33
|
+
freealg/_free_form/_plot_util.py
|
|
34
|
+
freealg/_free_form/_sample.py
|
|
35
|
+
freealg/_free_form/_series.py
|
|
36
|
+
freealg/_free_form/_support.py
|
|
37
|
+
freealg/_free_form/free_form.py
|
|
38
38
|
freealg/_geometric_form/__init__.py
|
|
39
39
|
freealg/_geometric_form/_continuation_genus0.py
|
|
40
40
|
freealg/_geometric_form/_continuation_genus1.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.7.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/freealg-0.7.1/freealg/_freeform/freeform.py → /freealg-0.7.3/freealg/_free_form/free_form.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|