freealg 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl
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/__version__.py +1 -1
- freealg/_plot_util.py +6 -6
- freealg/distributions/kesten_mckay.py +20 -5
- freealg/distributions/marchenko_pastur.py +20 -5
- freealg/distributions/wachter.py +20 -5
- freealg/distributions/wigner.py +20 -5
- freealg/freeform.py +2 -2
- {freealg-0.1.3.dist-info → freealg-0.1.5.dist-info}/METADATA +1 -1
- freealg-0.1.5.dist-info/RECORD +21 -0
- freealg-0.1.3.dist-info/RECORD +0 -21
- {freealg-0.1.3.dist-info → freealg-0.1.5.dist-info}/WHEEL +0 -0
- {freealg-0.1.3.dist-info → freealg-0.1.5.dist-info}/licenses/LICENSE.txt +0 -0
- {freealg-0.1.3.dist-info → freealg-0.1.5.dist-info}/top_level.txt +0 -0
freealg/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.5"
|
freealg/_plot_util.py
CHANGED
|
@@ -275,8 +275,8 @@ def plot_stieltjes(x, y, m1, m2, support, latex=False, save=False):
|
|
|
275
275
|
ax0.plot([lam_m, lam_p], [eps, eps], '-', linewidth=1, color='black')
|
|
276
276
|
ax0.set_xlabel(r'$\mathrm{Re}(z)$')
|
|
277
277
|
ax0.set_ylabel(r'$\mathrm{Im}(z)$')
|
|
278
|
-
ax0.set_title(r'(a) Principal Branch on $\mathbb{
|
|
279
|
-
r'$\mathbb{
|
|
278
|
+
ax0.set_title(r'(a) Principal Branch on $\mathbb{C}^{+}$ and ' +
|
|
279
|
+
r'$\mathbb{C}^{-}$')
|
|
280
280
|
ax0.set_yticks(numpy.arange(y_min, y_max+0.01, 0.5))
|
|
281
281
|
ax0.set_xlim([x_min, x_max])
|
|
282
282
|
ax0.set_ylim([y_min, y_max])
|
|
@@ -291,8 +291,8 @@ def plot_stieltjes(x, y, m1, m2, support, latex=False, save=False):
|
|
|
291
291
|
ax1.plot([lam_p, x_max], [eps, eps], '-', linewidth=1, color='black')
|
|
292
292
|
ax1.set_xlabel(r'$\mathrm{Re}(z)$')
|
|
293
293
|
ax1.set_ylabel(r'$\mathrm{Im}(z)$')
|
|
294
|
-
ax1.set_title(r'(b) Principal Branch on $\mathbb{
|
|
295
|
-
r'Branch on $\mathbb{
|
|
294
|
+
ax1.set_title(r'(b) Principal Branch on $\mathbb{C}^{+}$, Secondary ' +
|
|
295
|
+
r'Branch on $\mathbb{C}^{-}$')
|
|
296
296
|
ax1.set_yticks(numpy.arange(y_min, y_max+0.01, 0.5))
|
|
297
297
|
ax1.set_xlim([x_min, x_max])
|
|
298
298
|
ax1.set_ylim([y_min, y_max])
|
|
@@ -503,9 +503,9 @@ def plot_samples(x, rho, x_min, x_max, samples, latex=False, save=False):
|
|
|
503
503
|
|
|
504
504
|
fig, ax = plt.subplots(figsize=(6, 3))
|
|
505
505
|
|
|
506
|
-
bins = numpy.linspace(x_min, x_max, samples.size //
|
|
506
|
+
bins = numpy.linspace(x_min, x_max, samples.size // 15)
|
|
507
507
|
_ = ax.hist(samples, bins, density=True, color='silver',
|
|
508
|
-
label='Samples histogram')
|
|
508
|
+
edgecolor='none', label='Samples histogram')
|
|
509
509
|
ax.plot(x, rho, color='black', label='Exact density')
|
|
510
510
|
ax.legend(fontsize='small')
|
|
511
511
|
ax.set_ylim(bottom=0)
|
|
@@ -21,6 +21,7 @@ try:
|
|
|
21
21
|
from scipy.integrate import cumtrapz
|
|
22
22
|
except ImportError:
|
|
23
23
|
from scipy.integrate import cumulative_trapezoid as cumtrapz
|
|
24
|
+
from scipy.stats import qmc
|
|
24
25
|
|
|
25
26
|
__all__ = ['KestenMcKay']
|
|
26
27
|
|
|
@@ -429,8 +430,8 @@ class KestenMcKay(object):
|
|
|
429
430
|
# sample
|
|
430
431
|
# ======
|
|
431
432
|
|
|
432
|
-
def sample(self, size, x_min=None, x_max=None,
|
|
433
|
-
save=False):
|
|
433
|
+
def sample(self, size, x_min=None, x_max=None, method='qmc', plot=False,
|
|
434
|
+
latex=False, save=False):
|
|
434
435
|
"""
|
|
435
436
|
Sample from distribution.
|
|
436
437
|
|
|
@@ -448,6 +449,12 @@ class KestenMcKay(object):
|
|
|
448
449
|
Maximum of sample values. If `None`, the right edge of the support
|
|
449
450
|
is used.
|
|
450
451
|
|
|
452
|
+
method : {``'mc'``, ``'qmc'``}, default= ``'qmc'``
|
|
453
|
+
Method of drawing samples from uniform distirbution:
|
|
454
|
+
|
|
455
|
+
* ``'mc'``: Monte Carlo
|
|
456
|
+
* ``'qmc'``: Quasi Monte Carlo
|
|
457
|
+
|
|
451
458
|
plot : bool, default=False
|
|
452
459
|
If `True`, samples histogram is plotted.
|
|
453
460
|
|
|
@@ -503,9 +510,17 @@ class KestenMcKay(object):
|
|
|
503
510
|
inv_cdf = interp1d(cdf, xs, bounds_error=False,
|
|
504
511
|
fill_value=(x_min, x_max))
|
|
505
512
|
|
|
506
|
-
#
|
|
507
|
-
|
|
508
|
-
|
|
513
|
+
# Draw from uniform distribution
|
|
514
|
+
if method == 'mc':
|
|
515
|
+
u = numpy.random.rand(size)
|
|
516
|
+
elif method == 'qmc':
|
|
517
|
+
engine = qmc.Halton(d=1)
|
|
518
|
+
u = engine.random(size)
|
|
519
|
+
else:
|
|
520
|
+
raise ValueError('"method" is invalid.')
|
|
521
|
+
|
|
522
|
+
# Draw from distribution by mapping from inverse CDF
|
|
523
|
+
samples = inv_cdf(u).ravel()
|
|
509
524
|
|
|
510
525
|
if plot:
|
|
511
526
|
radius = 0.5 * (self.lam_p - self.lam_m)
|
|
@@ -20,6 +20,7 @@ try:
|
|
|
20
20
|
from scipy.integrate import cumtrapz
|
|
21
21
|
except ImportError:
|
|
22
22
|
from scipy.integrate import cumulative_trapezoid as cumtrapz
|
|
23
|
+
from scipy.stats import qmc
|
|
23
24
|
|
|
24
25
|
__all__ = ['MarchenkoPastur']
|
|
25
26
|
|
|
@@ -435,8 +436,8 @@ class MarchenkoPastur(object):
|
|
|
435
436
|
# sample
|
|
436
437
|
# ======
|
|
437
438
|
|
|
438
|
-
def sample(self, size, x_min=None, x_max=None,
|
|
439
|
-
save=False):
|
|
439
|
+
def sample(self, size, x_min=None, x_max=None, method='qmc', plot=False,
|
|
440
|
+
latex=False, save=False):
|
|
440
441
|
"""
|
|
441
442
|
Sample from distribution.
|
|
442
443
|
|
|
@@ -454,6 +455,12 @@ class MarchenkoPastur(object):
|
|
|
454
455
|
Maximum of sample values. If `None`, the right edge of the support
|
|
455
456
|
is used.
|
|
456
457
|
|
|
458
|
+
method : {``'mc'``, ``'qmc'``}, default= ``'qmc'``
|
|
459
|
+
Method of drawing samples from uniform distirbution:
|
|
460
|
+
|
|
461
|
+
* ``'mc'``: Monte Carlo
|
|
462
|
+
* ``'qmc'``: Quasi Monte Carlo
|
|
463
|
+
|
|
457
464
|
plot : bool, default=False
|
|
458
465
|
If `True`, samples histogram is plotted.
|
|
459
466
|
|
|
@@ -509,9 +516,17 @@ class MarchenkoPastur(object):
|
|
|
509
516
|
inv_cdf = interp1d(cdf, xs, bounds_error=False,
|
|
510
517
|
fill_value=(x_min, x_max))
|
|
511
518
|
|
|
512
|
-
#
|
|
513
|
-
|
|
514
|
-
|
|
519
|
+
# Draw from uniform distribution
|
|
520
|
+
if method == 'mc':
|
|
521
|
+
u = numpy.random.rand(size)
|
|
522
|
+
elif method == 'qmc':
|
|
523
|
+
engine = qmc.Halton(d=1)
|
|
524
|
+
u = engine.random(size)
|
|
525
|
+
else:
|
|
526
|
+
raise ValueError('"method" is invalid.')
|
|
527
|
+
|
|
528
|
+
# Draw from distribution by mapping from inverse CDF
|
|
529
|
+
samples = inv_cdf(u).ravel()
|
|
515
530
|
|
|
516
531
|
if plot:
|
|
517
532
|
radius = 0.5 * (self.lam_p - self.lam_m)
|
freealg/distributions/wachter.py
CHANGED
|
@@ -20,6 +20,7 @@ try:
|
|
|
20
20
|
from scipy.integrate import cumtrapz
|
|
21
21
|
except ImportError:
|
|
22
22
|
from scipy.integrate import cumulative_trapezoid as cumtrapz
|
|
23
|
+
from scipy.stats import qmc
|
|
23
24
|
|
|
24
25
|
__all__ = ['Wachter']
|
|
25
26
|
|
|
@@ -432,8 +433,8 @@ class Wachter(object):
|
|
|
432
433
|
# sample
|
|
433
434
|
# ======
|
|
434
435
|
|
|
435
|
-
def sample(self, size, x_min=None, x_max=None,
|
|
436
|
-
save=False):
|
|
436
|
+
def sample(self, size, x_min=None, x_max=None, method='qmc', plot=False,
|
|
437
|
+
latex=False, save=False):
|
|
437
438
|
"""
|
|
438
439
|
Sample from distribution.
|
|
439
440
|
|
|
@@ -451,6 +452,12 @@ class Wachter(object):
|
|
|
451
452
|
Maximum of sample values. If `None`, the right edge of the support
|
|
452
453
|
is used.
|
|
453
454
|
|
|
455
|
+
method : {``'mc'``, ``'qmc'``}, default= ``'qmc'``
|
|
456
|
+
Method of drawing samples from uniform distirbution:
|
|
457
|
+
|
|
458
|
+
* ``'mc'``: Monte Carlo
|
|
459
|
+
* ``'qmc'``: Quasi Monte Carlo
|
|
460
|
+
|
|
454
461
|
plot : bool, default=False
|
|
455
462
|
If `True`, samples histogram is plotted.
|
|
456
463
|
|
|
@@ -506,9 +513,17 @@ class Wachter(object):
|
|
|
506
513
|
inv_cdf = interp1d(cdf, xs, bounds_error=False,
|
|
507
514
|
fill_value=(x_min, x_max))
|
|
508
515
|
|
|
509
|
-
#
|
|
510
|
-
|
|
511
|
-
|
|
516
|
+
# Draw from uniform distribution
|
|
517
|
+
if method == 'mc':
|
|
518
|
+
u = numpy.random.rand(size)
|
|
519
|
+
elif method == 'qmc':
|
|
520
|
+
engine = qmc.Halton(d=1)
|
|
521
|
+
u = engine.random(size)
|
|
522
|
+
else:
|
|
523
|
+
raise ValueError('"method" is invalid.')
|
|
524
|
+
|
|
525
|
+
# Draw from distribution by mapping from inverse CDF
|
|
526
|
+
samples = inv_cdf(u).ravel()
|
|
512
527
|
|
|
513
528
|
if plot:
|
|
514
529
|
radius = 0.5 * (self.lam_p - self.lam_m)
|
freealg/distributions/wigner.py
CHANGED
|
@@ -21,6 +21,7 @@ try:
|
|
|
21
21
|
from scipy.integrate import cumtrapz
|
|
22
22
|
except ImportError:
|
|
23
23
|
from scipy.integrate import cumulative_trapezoid as cumtrapz
|
|
24
|
+
from scipy.stats import qmc
|
|
24
25
|
|
|
25
26
|
__all__ = ['Wigner']
|
|
26
27
|
|
|
@@ -416,8 +417,8 @@ class Wigner(object):
|
|
|
416
417
|
# sample
|
|
417
418
|
# ======
|
|
418
419
|
|
|
419
|
-
def sample(self, size, x_min=None, x_max=None,
|
|
420
|
-
save=False):
|
|
420
|
+
def sample(self, size, x_min=None, x_max=None, method='qmc', plot=False,
|
|
421
|
+
latex=False, save=False):
|
|
421
422
|
"""
|
|
422
423
|
Sample from distribution.
|
|
423
424
|
|
|
@@ -435,6 +436,12 @@ class Wigner(object):
|
|
|
435
436
|
Maximum of sample values. If `None`, the right edge of the support
|
|
436
437
|
is used.
|
|
437
438
|
|
|
439
|
+
method : {``'mc'``, ``'qmc'``}, default= ``'qmc'``
|
|
440
|
+
Method of drawing samples from uniform distirbution:
|
|
441
|
+
|
|
442
|
+
* ``'mc'``: Monte Carlo
|
|
443
|
+
* ``'qmc'``: Quasi Monte Carlo
|
|
444
|
+
|
|
438
445
|
plot : bool, default=False
|
|
439
446
|
If `True`, samples histogram is plotted.
|
|
440
447
|
|
|
@@ -490,9 +497,17 @@ class Wigner(object):
|
|
|
490
497
|
inv_cdf = interp1d(cdf, xs, bounds_error=False,
|
|
491
498
|
fill_value=(x_min, x_max))
|
|
492
499
|
|
|
493
|
-
#
|
|
494
|
-
|
|
495
|
-
|
|
500
|
+
# Draw from uniform distribution
|
|
501
|
+
if method == 'mc':
|
|
502
|
+
u = numpy.random.rand(size)
|
|
503
|
+
elif method == 'qmc':
|
|
504
|
+
engine = qmc.Halton(d=1)
|
|
505
|
+
u = engine.random(size)
|
|
506
|
+
else:
|
|
507
|
+
raise ValueError('"method" is invalid.')
|
|
508
|
+
|
|
509
|
+
# Draw from distribution by mapping from inverse CDF
|
|
510
|
+
samples = inv_cdf(u).ravel()
|
|
496
511
|
|
|
497
512
|
if plot:
|
|
498
513
|
radius = 0.5 * (self.lam_p - self.lam_m)
|
freealg/freeform.py
CHANGED
|
@@ -207,7 +207,7 @@ class FreeForm(object):
|
|
|
207
207
|
Tikhonov regularization coefficient.
|
|
208
208
|
|
|
209
209
|
projection : {``'sample'``, ``'gaussian'``, ``'beta'``}, \
|
|
210
|
-
default= ``'
|
|
210
|
+
default= ``'beta'``
|
|
211
211
|
The method of Galerkin projection:
|
|
212
212
|
|
|
213
213
|
* ``'sample'``: directly project samples (eigenvalues) to the
|
|
@@ -220,7 +220,7 @@ class FreeForm(object):
|
|
|
220
220
|
project a smooth KDE to the orthogonal polynomials. This method
|
|
221
221
|
is stable.
|
|
222
222
|
|
|
223
|
-
kernel_bw : float, default=
|
|
223
|
+
kernel_bw : float, default=0.001
|
|
224
224
|
Kernel band-wdth. See scipy.stats.gaussian_kde. This argument is
|
|
225
225
|
relevant if ``projection='kernel'`` is set.
|
|
226
226
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
freealg/__init__.py,sha256=K92neXJZ9VE1U_j_pj28Qyq1MzlMXhOuYK2ZihgwCaU,463
|
|
2
|
+
freealg/__version__.py,sha256=rPSfWgIeq2YWVPyESOAwCBt8vftsTpIkuLAGDEzyRQc,22
|
|
3
|
+
freealg/_chebyshev.py,sha256=X6u5pKjR1HPZ-KbCfr7zT6HRwB6pZMADvVS3sT5LTkA,5638
|
|
4
|
+
freealg/_damp.py,sha256=k2vtBtWOxQBf4qXaWu_En81lQBXbEO4QbxxWpvuVhdE,1802
|
|
5
|
+
freealg/_decompress.py,sha256=H7ocq09gQnCY-q_8xHi6qyYj3qp239MCgj406hn0yeE,3344
|
|
6
|
+
freealg/_jacobi.py,sha256=AT4ONSHGGDxVKE3MGMLyMR8uDFiO-e9u3x5udYfdJJk,5635
|
|
7
|
+
freealg/_pade.py,sha256=mP96wEPfIzHLZ6PDB5OyhmSA8N1uVPVUkmJa3ebXXiU,13623
|
|
8
|
+
freealg/_plot_util.py,sha256=wVx99GRdIFu_wzmG8f5JSDZ65BJohnuSBm3mZ58wElg,18426
|
|
9
|
+
freealg/_sample.py,sha256=K1ZxKoiuPbEKyh-swL5X7gz1kYcQno6Mof0o1xF38tg,2323
|
|
10
|
+
freealg/_util.py,sha256=alJ9s1U_sHL7dXq7hI10fa8CF_AZ6Xmy_QsoyDYPSDQ,3677
|
|
11
|
+
freealg/freeform.py,sha256=kbh7UoOJkAVFKj2Zmddy803-asoslkqn-gWJ-HpLN7U,28750
|
|
12
|
+
freealg/distributions/__init__.py,sha256=Hnk9bJi4Wy8I_1uuskRyrT2DUpPN1YmBY5uK7XI3U_o,644
|
|
13
|
+
freealg/distributions/kesten_mckay.py,sha256=Oq2FCX60seojy7LDn8nYPrbqinmXv4YC-93VxlmDQ6M,15913
|
|
14
|
+
freealg/distributions/marchenko_pastur.py,sha256=GwDTN-7au2h7H7PnZkQfs6bas8fNhgEnQ-hTWsBMZuE,16403
|
|
15
|
+
freealg/distributions/wachter.py,sha256=2eqbJY4S1MqLjgqO6qY06m3-_s-bKTuSiryS_ZH_xvI,16136
|
|
16
|
+
freealg/distributions/wigner.py,sha256=MSrB-HLMzOwnWDDzw5XPLsoL4LEIV35w5jWeL-qDn9Y,15448
|
|
17
|
+
freealg-0.1.5.dist-info/licenses/LICENSE.txt,sha256=J-EEYEtxb3VVf_Bn1TYfWnpY5lMFIM15iLDDcnaDTPA,1443
|
|
18
|
+
freealg-0.1.5.dist-info/METADATA,sha256=sG6aPyglynO4hXzXNnMPDliEtC5JLlrOMy84e_KMDzU,2939
|
|
19
|
+
freealg-0.1.5.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
20
|
+
freealg-0.1.5.dist-info/top_level.txt,sha256=eR2wrgYwDdnnJ9Zf5PruPqe4kQav0GMvRsqct6y00Q8,8
|
|
21
|
+
freealg-0.1.5.dist-info/RECORD,,
|
freealg-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
freealg/__init__.py,sha256=K92neXJZ9VE1U_j_pj28Qyq1MzlMXhOuYK2ZihgwCaU,463
|
|
2
|
-
freealg/__version__.py,sha256=XEqb2aiIn8fzGE68Mph4ck1FtQqsR_am0wRWvrYPffQ,22
|
|
3
|
-
freealg/_chebyshev.py,sha256=X6u5pKjR1HPZ-KbCfr7zT6HRwB6pZMADvVS3sT5LTkA,5638
|
|
4
|
-
freealg/_damp.py,sha256=k2vtBtWOxQBf4qXaWu_En81lQBXbEO4QbxxWpvuVhdE,1802
|
|
5
|
-
freealg/_decompress.py,sha256=H7ocq09gQnCY-q_8xHi6qyYj3qp239MCgj406hn0yeE,3344
|
|
6
|
-
freealg/_jacobi.py,sha256=AT4ONSHGGDxVKE3MGMLyMR8uDFiO-e9u3x5udYfdJJk,5635
|
|
7
|
-
freealg/_pade.py,sha256=mP96wEPfIzHLZ6PDB5OyhmSA8N1uVPVUkmJa3ebXXiU,13623
|
|
8
|
-
freealg/_plot_util.py,sha256=aL0u7FHdCwLTj4dZ4SSGA00wab0Voem2nBAsBVvo6XY,18400
|
|
9
|
-
freealg/_sample.py,sha256=K1ZxKoiuPbEKyh-swL5X7gz1kYcQno6Mof0o1xF38tg,2323
|
|
10
|
-
freealg/_util.py,sha256=alJ9s1U_sHL7dXq7hI10fa8CF_AZ6Xmy_QsoyDYPSDQ,3677
|
|
11
|
-
freealg/freeform.py,sha256=s7uOV1J9v2urHrnWspnyyiYSW_vb4gcny3e4n21R3rs,28753
|
|
12
|
-
freealg/distributions/__init__.py,sha256=Hnk9bJi4Wy8I_1uuskRyrT2DUpPN1YmBY5uK7XI3U_o,644
|
|
13
|
-
freealg/distributions/kesten_mckay.py,sha256=SFYg2_6_MEX9NGfOIW_rRfM9kgF-bdjQiVS0ENJBemQ,15379
|
|
14
|
-
freealg/distributions/marchenko_pastur.py,sha256=0XHhjw1ZDkigGfjU9lmPRgmwecM1-n6VBkGjRJbxpeY,15869
|
|
15
|
-
freealg/distributions/wachter.py,sha256=cG-3XTP5CHSK5o6SQfa3lqQR__ZibeWZ9AoeMxr3Nnk,15602
|
|
16
|
-
freealg/distributions/wigner.py,sha256=gj3XWK4X7wLsB-inoVpn4pHUUM7NOQdgMGw01LEqkcw,14914
|
|
17
|
-
freealg-0.1.3.dist-info/licenses/LICENSE.txt,sha256=J-EEYEtxb3VVf_Bn1TYfWnpY5lMFIM15iLDDcnaDTPA,1443
|
|
18
|
-
freealg-0.1.3.dist-info/METADATA,sha256=vP6rSm1E4F6pwHJsb4Ji0xN3YYLiJs4UInsPn7Np9yU,2939
|
|
19
|
-
freealg-0.1.3.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
20
|
-
freealg-0.1.3.dist-info/top_level.txt,sha256=eR2wrgYwDdnnJ9Zf5PruPqe4kQav0GMvRsqct6y00Q8,8
|
|
21
|
-
freealg-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|