freealg 0.1.9__tar.gz → 0.1.10__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.1.9 → freealg-0.1.10}/PKG-INFO +1 -1
- {freealg-0.1.9 → freealg-0.1.10}/freealg/__init__.py +2 -1
- freealg-0.1.10/freealg/__version__.py +1 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_plot_util.py +55 -2
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_sample.py +2 -1
- {freealg-0.1.9 → freealg-0.1.10}/freealg/distributions/__init__.py +5 -5
- freealg-0.1.9/freealg/distributions/kesten_mckay.py → freealg-0.1.10/freealg/distributions/_kesten_mckay.py +2 -1
- freealg-0.1.9/freealg/distributions/marchenko_pastur.py → freealg-0.1.10/freealg/distributions/_marchenko_pastur.py +4 -2
- freealg-0.1.9/freealg/distributions/meixner.py → freealg-0.1.10/freealg/distributions/_meixner.py +2 -1
- freealg-0.1.9/freealg/distributions/wachter.py → freealg-0.1.10/freealg/distributions/_wachter.py +4 -2
- freealg-0.1.9/freealg/distributions/wigner.py → freealg-0.1.10/freealg/distributions/_wigner.py +4 -2
- {freealg-0.1.9 → freealg-0.1.10}/freealg/freeform.py +4 -8
- {freealg-0.1.9 → freealg-0.1.10}/freealg.egg-info/PKG-INFO +1 -1
- {freealg-0.1.9 → freealg-0.1.10}/freealg.egg-info/SOURCES.txt +5 -5
- freealg-0.1.9/freealg/__version__.py +0 -1
- {freealg-0.1.9 → freealg-0.1.10}/AUTHORS.txt +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/CHANGELOG.rst +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/LICENSE.txt +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/MANIFEST.in +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/README.rst +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_chebyshev.py +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_damp.py +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_decompress.py +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_jacobi.py +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_pade.py +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg/_util.py +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg.egg-info/dependency_links.txt +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg.egg-info/not-zip-safe +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg.egg-info/requires.txt +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/freealg.egg-info/top_level.txt +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/pyproject.toml +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/requirements.txt +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/setup.cfg +0 -0
- {freealg-0.1.9 → freealg-0.1.10}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.10"
|
|
@@ -81,6 +81,59 @@ def plot_fit(psi, x_supp, g_supp, g_supp_approx, support, latex=False,
|
|
|
81
81
|
show_and_save=save_status, verbose=True)
|
|
82
82
|
|
|
83
83
|
|
|
84
|
+
# =========
|
|
85
|
+
# auto bins
|
|
86
|
+
# =========
|
|
87
|
+
|
|
88
|
+
def _auto_bins(array, method='scott', factor=5):
|
|
89
|
+
"""
|
|
90
|
+
Automatic choice for the number of bins for the histogram of an array.
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
|
|
95
|
+
array : numpy.array
|
|
96
|
+
An array for histogram.
|
|
97
|
+
|
|
98
|
+
method : {``'freedman'``, ``'scott'``, ``'sturges'``}, default= ``'scott'``
|
|
99
|
+
Method of choosing number of bins.
|
|
100
|
+
|
|
101
|
+
Returns
|
|
102
|
+
-------
|
|
103
|
+
|
|
104
|
+
num_bins : int
|
|
105
|
+
Number of bins for histogram.
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
if method == 'freedman':
|
|
109
|
+
|
|
110
|
+
q75, q25 = numpy.percentile(array, [75, 25])
|
|
111
|
+
iqr = q75 - q25
|
|
112
|
+
bin_width = 2 * iqr / (len(array) ** (1/3))
|
|
113
|
+
|
|
114
|
+
if bin_width == 0:
|
|
115
|
+
# Fallback default
|
|
116
|
+
return
|
|
117
|
+
num_bins = 100
|
|
118
|
+
else:
|
|
119
|
+
num_bins = int(numpy.ceil((array.max() - array.min()) / bin_width))
|
|
120
|
+
|
|
121
|
+
elif method == 'scott':
|
|
122
|
+
|
|
123
|
+
std = numpy.std(array)
|
|
124
|
+
bin_width = 3.5 * std / (len(array) ** (1/3))
|
|
125
|
+
num_bins = int(numpy.ceil((array.max() - array.min()) / bin_width))
|
|
126
|
+
|
|
127
|
+
elif method == 'sturges':
|
|
128
|
+
|
|
129
|
+
num_bins = int(numpy.ceil(numpy.log2(len(array)) + 1))
|
|
130
|
+
|
|
131
|
+
else:
|
|
132
|
+
raise ValueError('"method" is invalid.')
|
|
133
|
+
|
|
134
|
+
return num_bins * factor
|
|
135
|
+
|
|
136
|
+
|
|
84
137
|
# ============
|
|
85
138
|
# plot density
|
|
86
139
|
# ============
|
|
@@ -96,7 +149,7 @@ def plot_density(x, rho, eig=None, support=None, label='',
|
|
|
96
149
|
|
|
97
150
|
if (support is not None) and (eig is not None):
|
|
98
151
|
lam_m, lam_p = support
|
|
99
|
-
bins = numpy.linspace(lam_m, lam_p,
|
|
152
|
+
bins = numpy.linspace(lam_m, lam_p, _auto_bins(eig))
|
|
100
153
|
_ = ax.hist(eig, bins, density=True, color='silver',
|
|
101
154
|
edgecolor='none', label='Histogram')
|
|
102
155
|
else:
|
|
@@ -503,7 +556,7 @@ def plot_samples(x, rho, x_min, x_max, samples, latex=False, save=False):
|
|
|
503
556
|
|
|
504
557
|
fig, ax = plt.subplots(figsize=(6, 3))
|
|
505
558
|
|
|
506
|
-
bins = numpy.linspace(x_min, x_max, samples
|
|
559
|
+
bins = numpy.linspace(x_min, x_max, _auto_bins(samples))
|
|
507
560
|
_ = ax.hist(samples, bins, density=True, color='silver',
|
|
508
561
|
edgecolor='none', label='Samples histogram')
|
|
509
562
|
ax.plot(x, rho, color='black', label='Exact density')
|
|
@@ -6,10 +6,10 @@
|
|
|
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 .
|
|
10
|
-
from .
|
|
11
|
-
from .
|
|
12
|
-
from .
|
|
13
|
-
from .
|
|
9
|
+
from ._marchenko_pastur import MarchenkoPastur
|
|
10
|
+
from ._wigner import Wigner
|
|
11
|
+
from ._kesten_mckay import KestenMcKay
|
|
12
|
+
from ._wachter import Wachter
|
|
13
|
+
from ._meixner import Meixner
|
|
14
14
|
|
|
15
15
|
__all__ = ['MarchenkoPastur', 'Wigner', 'KestenMcKay', 'Wachter', 'Meixner']
|
|
@@ -501,7 +501,8 @@ class MarchenkoPastur(object):
|
|
|
501
501
|
:class: custom-dark
|
|
502
502
|
"""
|
|
503
503
|
|
|
504
|
-
|
|
504
|
+
if seed is not None:
|
|
505
|
+
numpy.random.seed(seed)
|
|
505
506
|
|
|
506
507
|
if x_min is None:
|
|
507
508
|
x_min = self.lam_m
|
|
@@ -578,7 +579,8 @@ class MarchenkoPastur(object):
|
|
|
578
579
|
>>> A = mp.matrix(2000)
|
|
579
580
|
"""
|
|
580
581
|
|
|
581
|
-
|
|
582
|
+
if seed is not None:
|
|
583
|
+
numpy.random.seed(seed)
|
|
582
584
|
|
|
583
585
|
# Parameters
|
|
584
586
|
m = int(size / self.lam)
|
freealg-0.1.9/freealg/distributions/wachter.py → freealg-0.1.10/freealg/distributions/_wachter.py
RENAMED
|
@@ -501,7 +501,8 @@ class Wachter(object):
|
|
|
501
501
|
:class: custom-dark
|
|
502
502
|
"""
|
|
503
503
|
|
|
504
|
-
|
|
504
|
+
if seed is not None:
|
|
505
|
+
numpy.random.seed(seed)
|
|
505
506
|
|
|
506
507
|
if x_min is None:
|
|
507
508
|
x_min = self.lam_m
|
|
@@ -581,7 +582,8 @@ class Wachter(object):
|
|
|
581
582
|
>>> A = wa.matrix(2000)
|
|
582
583
|
"""
|
|
583
584
|
|
|
584
|
-
|
|
585
|
+
if seed is not None:
|
|
586
|
+
numpy.random.seed(seed)
|
|
585
587
|
|
|
586
588
|
n = size
|
|
587
589
|
m1 = int(self.a * n)
|
freealg-0.1.9/freealg/distributions/wigner.py → freealg-0.1.10/freealg/distributions/_wigner.py
RENAMED
|
@@ -478,7 +478,8 @@ class Wigner(object):
|
|
|
478
478
|
:class: custom-dark
|
|
479
479
|
"""
|
|
480
480
|
|
|
481
|
-
|
|
481
|
+
if seed is not None:
|
|
482
|
+
numpy.random.seed(seed)
|
|
482
483
|
|
|
483
484
|
if x_min is None:
|
|
484
485
|
x_min = self.lam_m
|
|
@@ -555,7 +556,8 @@ class Wigner(object):
|
|
|
555
556
|
>>> A = wg.matrix(2000)
|
|
556
557
|
"""
|
|
557
558
|
|
|
558
|
-
|
|
559
|
+
if seed is not None:
|
|
560
|
+
numpy.random.seed(seed)
|
|
559
561
|
|
|
560
562
|
# Parameters
|
|
561
563
|
n = size
|
|
@@ -499,17 +499,13 @@ class FreeForm(object):
|
|
|
499
499
|
# Check density is unit mass
|
|
500
500
|
mass = numpy.trapz(rho, x)
|
|
501
501
|
if not numpy.isclose(mass, 1.0, atol=1e-2):
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
print(f'"rho" is not unit mass. mass: {mass}. Set "force=True".')
|
|
502
|
+
print(f'"rho" is not unit mass. mass: {mass:>0.3f}. Set ' +
|
|
503
|
+
r'"force=True".')
|
|
505
504
|
|
|
506
505
|
# Check density is positive
|
|
507
506
|
min_rho = numpy.min(rho)
|
|
508
507
|
if min_rho < 0.0 - 1e-3:
|
|
509
|
-
|
|
510
|
-
# f'"rho" is not positive. min_rho: {min_rho}. Set ' +
|
|
511
|
-
# r'"force=True".')
|
|
512
|
-
print(f'"rho" is not positive. min_rho: {min_rho}. Set ' +
|
|
508
|
+
print(f'"rho" is not positive. min_rho: {min_rho:>0.3f}. Set ' +
|
|
513
509
|
r'"force=True".')
|
|
514
510
|
|
|
515
511
|
if plot:
|
|
@@ -631,7 +627,7 @@ class FreeForm(object):
|
|
|
631
627
|
# stieltjes
|
|
632
628
|
# =========
|
|
633
629
|
|
|
634
|
-
def stieltjes(self, x, y, plot=False, latex=False, save=False):
|
|
630
|
+
def stieltjes(self, x=None, y=None, plot=False, latex=False, save=False):
|
|
635
631
|
"""
|
|
636
632
|
Compute Stieltjes transform of the spectral density over a 2D Cartesian
|
|
637
633
|
grid on the complex plane.
|
|
@@ -25,8 +25,8 @@ freealg.egg-info/not-zip-safe
|
|
|
25
25
|
freealg.egg-info/requires.txt
|
|
26
26
|
freealg.egg-info/top_level.txt
|
|
27
27
|
freealg/distributions/__init__.py
|
|
28
|
-
freealg/distributions/
|
|
29
|
-
freealg/distributions/
|
|
30
|
-
freealg/distributions/
|
|
31
|
-
freealg/distributions/
|
|
32
|
-
freealg/distributions/
|
|
28
|
+
freealg/distributions/_kesten_mckay.py
|
|
29
|
+
freealg/distributions/_marchenko_pastur.py
|
|
30
|
+
freealg/distributions/_meixner.py
|
|
31
|
+
freealg/distributions/_wachter.py
|
|
32
|
+
freealg/distributions/_wigner.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.9"
|
|
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
|