mc3 3.1.2__tar.gz → 3.1.4__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.
Files changed (79) hide show
  1. {mc3-3.1.2 → mc3-3.1.4}/MANIFEST.in +0 -2
  2. mc3-3.1.4/PKG-INFO +78 -0
  3. {mc3-3.1.2 → mc3-3.1.4}/docs/get_started.rst +8 -13
  4. {mc3-3.1.2 → mc3-3.1.4}/docs/index.rst +1 -1
  5. {mc3-3.1.2 → mc3-3.1.4}/mc3/__main__.py +2 -3
  6. {mc3-3.1.2 → mc3-3.1.4}/mc3/plots/colors.py +1 -1
  7. {mc3-3.1.2 → mc3-3.1.4}/mc3/sampler_driver.py +0 -36
  8. {mc3-3.1.2 → mc3-3.1.4}/mc3/stats/stats.py +60 -35
  9. {mc3-3.1.2 → mc3-3.1.4}/mc3/version.py +1 -1
  10. mc3-3.1.4/mc3.egg-info/PKG-INFO +78 -0
  11. {mc3-3.1.2 → mc3-3.1.4}/mc3.egg-info/SOURCES.txt +0 -5
  12. {mc3-3.1.2 → mc3-3.1.4}/mc3.egg-info/entry_points.txt +0 -1
  13. {mc3-3.1.2 → mc3-3.1.4}/mc3.egg-info/requires.txt +3 -0
  14. mc3-3.1.4/pyproject.toml +47 -0
  15. mc3-3.1.4/setup.py +38 -0
  16. {mc3-3.1.2 → mc3-3.1.4}/src_c/include/stats.h +6 -6
  17. {mc3-3.1.2 → mc3-3.1.4}/tests/test_plots.py +2 -2
  18. mc3-3.1.2/Makefile +0 -46
  19. mc3-3.1.2/PKG-INFO +0 -54
  20. mc3-3.1.2/examples/ns_tutorial.py +0 -77
  21. mc3-3.1.2/mc3/ns_driver.py +0 -216
  22. mc3-3.1.2/mc3/sampler.py +0 -386
  23. mc3-3.1.2/mc3.egg-info/PKG-INFO +0 -54
  24. mc3-3.1.2/pyproject.toml +0 -8
  25. mc3-3.1.2/setup.py +0 -71
  26. mc3-3.1.2/tests/test_dynesty.py +0 -165
  27. {mc3-3.1.2 → mc3-3.1.4}/.readthedocs.yml +0 -0
  28. {mc3-3.1.2 → mc3-3.1.4}/CONTRIBUTING.md +0 -0
  29. {mc3-3.1.2 → mc3-3.1.4}/LICENSE +0 -0
  30. {mc3-3.1.2 → mc3-3.1.4}/README.md +0 -0
  31. {mc3-3.1.2 → mc3-3.1.4}/docs/Makefile +0 -0
  32. {mc3-3.1.2 → mc3-3.1.4}/docs/api.rst +0 -0
  33. {mc3-3.1.2 → mc3-3.1.4}/docs/conf.py +0 -0
  34. {mc3-3.1.2 → mc3-3.1.4}/docs/contributing.rst +0 -0
  35. {mc3-3.1.2 → mc3-3.1.4}/docs/figures/quad_bestfit.png +0 -0
  36. {mc3-3.1.2 → mc3-3.1.4}/docs/figures/quad_fitting.png +0 -0
  37. {mc3-3.1.2 → mc3-3.1.4}/docs/figures/quad_hist.png +0 -0
  38. {mc3-3.1.2 → mc3-3.1.4}/docs/figures/quad_pairwise.png +0 -0
  39. {mc3-3.1.2 → mc3-3.1.4}/docs/figures/quad_trace.png +0 -0
  40. {mc3-3.1.2 → mc3-3.1.4}/docs/figures/rms-vs-binsize.png +0 -0
  41. {mc3-3.1.2 → mc3-3.1.4}/docs/fit_tutorial.rst +0 -0
  42. {mc3-3.1.2 → mc3-3.1.4}/docs/license.rst +0 -0
  43. {mc3-3.1.2 → mc3-3.1.4}/docs/make.bat +0 -0
  44. {mc3-3.1.2 → mc3-3.1.4}/docs/mcmc_tutorial.rst +0 -0
  45. {mc3-3.1.2 → mc3-3.1.4}/docs/references.rst +0 -0
  46. {mc3-3.1.2 → mc3-3.1.4}/docs/time_averaging.rst +0 -0
  47. {mc3-3.1.2 → mc3-3.1.4}/examples/get_started.py +0 -0
  48. {mc3-3.1.2 → mc3-3.1.4}/examples/timeavg.py +0 -0
  49. {mc3-3.1.2 → mc3-3.1.4}/examples/tutorial.py +0 -0
  50. {mc3-3.1.2 → mc3-3.1.4}/mc3/__init__.py +0 -0
  51. {mc3-3.1.2 → mc3-3.1.4}/mc3/chain.py +0 -0
  52. {mc3-3.1.2 → mc3-3.1.4}/mc3/fit_driver.py +0 -0
  53. {mc3-3.1.2 → mc3-3.1.4}/mc3/mcmc_driver.py +0 -0
  54. {mc3-3.1.2 → mc3-3.1.4}/mc3/plots/__init__.py +0 -0
  55. {mc3-3.1.2 → mc3-3.1.4}/mc3/plots/plot_functions.py +0 -0
  56. {mc3-3.1.2 → mc3-3.1.4}/mc3/plots/posterior.py +0 -0
  57. {mc3-3.1.2 → mc3-3.1.4}/mc3/stats/__init__.py +0 -0
  58. {mc3-3.1.2 → mc3-3.1.4}/mc3/stats/gelman.py +0 -0
  59. {mc3-3.1.2 → mc3-3.1.4}/mc3/stats/prayer.py +0 -0
  60. {mc3-3.1.2 → mc3-3.1.4}/mc3/stats/time_averaging.py +0 -0
  61. {mc3-3.1.2 → mc3-3.1.4}/mc3/utils/__init__.py +0 -0
  62. {mc3-3.1.2 → mc3-3.1.4}/mc3/utils/log.py +0 -0
  63. {mc3-3.1.2 → mc3-3.1.4}/mc3/utils/utils.py +0 -0
  64. {mc3-3.1.2 → mc3-3.1.4}/mc3.egg-info/dependency_links.txt +0 -0
  65. {mc3-3.1.2 → mc3-3.1.4}/mc3.egg-info/top_level.txt +0 -0
  66. {mc3-3.1.2 → mc3-3.1.4}/pytest.ini +0 -0
  67. {mc3-3.1.2 → mc3-3.1.4}/requirements.txt +0 -0
  68. {mc3-3.1.2 → mc3-3.1.4}/setup.cfg +0 -0
  69. {mc3-3.1.2 → mc3-3.1.4}/src_c/_binarray.c +0 -0
  70. {mc3-3.1.2 → mc3-3.1.4}/src_c/_chisq.c +0 -0
  71. {mc3-3.1.2 → mc3-3.1.4}/src_c/_dwt.c +0 -0
  72. {mc3-3.1.2 → mc3-3.1.4}/src_c/_time_averaging.c +0 -0
  73. {mc3-3.1.2 → mc3-3.1.4}/src_c/include/ind.h +0 -0
  74. {mc3-3.1.2 → mc3-3.1.4}/src_c/include/wavelet.h +0 -0
  75. {mc3-3.1.2 → mc3-3.1.4}/tests/test_fit.py +0 -0
  76. {mc3-3.1.2 → mc3-3.1.4}/tests/test_logging.py +0 -0
  77. {mc3-3.1.2 → mc3-3.1.4}/tests/test_mcmc.py +0 -0
  78. {mc3-3.1.2 → mc3-3.1.4}/tests/test_stats.py +0 -0
  79. {mc3-3.1.2 → mc3-3.1.4}/tests/test_utils.py +0 -0
@@ -3,10 +3,8 @@ include MANIFEST.in
3
3
  include requirements.txt
4
4
  include CONTRIBUTING.md
5
5
  include LICENSE
6
- include Makefile
7
6
  include pytest.ini
8
7
  include pyproject.toml
9
- include .travis.yml
10
8
  include .readthedocs.yml
11
9
  include docs/*.rst
12
10
  include docs/conf.py
mc3-3.1.4/PKG-INFO ADDED
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.1
2
+ Name: mc3
3
+ Version: 3.1.4
4
+ Summary: Multi-core Markov-chain Monte Carlo package
5
+ Author-email: Patricio Cubillos <patricio.cubillos@oeaw.ac.at>
6
+ License: Copyright (c) 2015-2022 Patricio Cubillos and contributors.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Project-URL: Homepage, https://github.com/pcubillos/mc3
27
+ Requires-Python: >=3.6
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy>=1.19.5
31
+ Requires-Dist: scipy>=1.5.4
32
+ Requires-Dist: matplotlib>=3.3.4
33
+ Provides-Extra: test
34
+ Requires-Dist: pytest>=6.0; extra == "test"
35
+
36
+ # mc3: Multi-core Markov-chain Monte Carlo
37
+ > A Python implementation of the Markov-chain Monte Carlo algorithm.
38
+
39
+ [![Tests](https://github.com/pcubillos/mc3/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/pcubillos/mc3/actions/workflows/python-package.yml)
40
+ [![Documentation Status](https://readthedocs.org/projects/mc3/badge/?version=latest)](https://mc3.readthedocs.io/en/latest/?badge=latest)
41
+ [![PyPI](https://img.shields.io/pypi/v/mc3.svg)](https://pypi.org/project/mc3)
42
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/mc3.svg)](https://anaconda.org/conda-forge/mc3)
43
+ [![GitHub](https://img.shields.io/github/license/pcubillos/mc3.svg?color=blue)](https://mc3.readthedocs.io/en/latest/license.html)
44
+
45
+ ### Install as:
46
+ ```
47
+ pip install mc3
48
+ ```
49
+ or:
50
+ ```
51
+ conda install -c conda-forge mc3
52
+ ```
53
+
54
+ ### Docs at:
55
+ <https://mc3.readthedocs.io/en/latest/>
56
+
57
+ ### Cite as:
58
+ ```bibtex
59
+ @ARTICLE{CubillosEtal2017apjRednoise,
60
+ author = {{Cubillos}, Patricio and {Harrington}, Joseph and {Loredo}, Thomas J. and {Lust}, Nate B. and {Blecic}, Jasmina and {Stemm}, Madison},
61
+ title = "{On Correlated-noise Analyses Applied to Exoplanet Light Curves}",
62
+ journal = {\aj},
63
+ keywords = {methods: statistical, planets and satellites: fundamental parameters, techniques: photometric, Astrophysics - Earth and Planetary Astrophysics},
64
+ year = 2017,
65
+ month = jan,
66
+ volume = {153},
67
+ number = {1},
68
+ eid = {3},
69
+ pages = {3},
70
+ doi = {10.3847/1538-3881/153/1/3},
71
+ archivePrefix = {arXiv},
72
+ eprint = {1610.01336},
73
+ primaryClass = {astro-ph.EP},
74
+ adsurl = {https://ui.adsabs.harvard.edu/abs/2017AJ....153....3C},
75
+ adsnote = {Provided by the SAO/NASA Astrophysics Data System}
76
+ }
77
+ ```
78
+
@@ -6,17 +6,8 @@ Getting Started
6
6
  System Requirements
7
7
  -------------------
8
8
 
9
- ``mc3`` is compatible with Python 3.6+, and has been `tested
10
- <https://github.com/pcubillos/mc3/actions/workflows/python-package.yml>`_ to work on Unix/Linux and
11
- OS X machines, with the following software:
12
-
13
- * Numpy >= 1.19.5
14
- * Scipy >= 1.9.3
15
- * Matplotlib >= 3.3.4
16
-
17
- ``mc3`` may work with previous versions of these software;
18
- however, we do not guarantee nor provide support for that.
19
-
9
+ ``mc3`` is compatible with Python 3.7+, and has been `tested
10
+ <https://github.com/pcubillos/mc3/actions/workflows/python-package.yml>`_ to work on Unix/Linux and OS X machines.
20
11
 
21
12
  Install
22
13
  -------
@@ -39,10 +30,11 @@ Alternatively (e.g., for developers), clone the repository to your local machine
39
30
 
40
31
  git clone https://github.com/pcubillos/mc3
41
32
  cd mc3
33
+ pip install -r requirements.txt
42
34
  pip install -e .
43
35
 
44
36
 
45
- ``mc3`` provides MCMC and nested-sampling posterior sampling,
37
+ ``mc3`` provides MCMC posterior sampling,
46
38
  optimization and other lower-level statistical and plotting
47
39
  routines. See the full docs in the :ref:`api` or through the Python
48
40
  interpreter:
@@ -52,10 +44,13 @@ interpreter:
52
44
  import mc3
53
45
  # Bayesian posterior sampling:
54
46
  help(mc3.sample)
47
+
55
48
  # Optimization:
56
49
  help(mc3.fit)
57
- # Assorted stats:
50
+
51
+ # Assorted stats utilities:
58
52
  help(mc3.stats)
53
+
59
54
  # Plotting utilities:
60
55
  help(mc3.plots)
61
56
 
@@ -40,7 +40,7 @@ mc3: Multi-Core Markov-Chain Monte Carlo
40
40
 
41
41
  .. note::
42
42
 
43
- Got Python3.6+? Simply install as: ``pip install mc3``
43
+ Got Python3.7+? Simply install as: ``pip install mc3``
44
44
 
45
45
 
46
46
  Features
@@ -7,9 +7,7 @@ import warnings
7
7
  import argparse
8
8
  import configparser
9
9
 
10
- import matplotlib as mpl
11
- if os.environ.get('DISPLAY', '') == '':
12
- mpl.use('Agg')
10
+ import matplotlib
13
11
  import matplotlib.pyplot as plt
14
12
 
15
13
  import mc3
@@ -236,6 +234,7 @@ def parse():
236
234
 
237
235
 
238
236
  if __name__ == "__main__":
237
+ matplotlib.use('Agg')
239
238
  plt.ioff()
240
239
  warnings.simplefilter("ignore", RuntimeWarning)
241
240
  main()
@@ -133,7 +133,7 @@ def rainbow_text(ax, texts, fontsize, colors=None, loc='above'):
133
133
 
134
134
  class Theme():
135
135
  """A monochromatic color theme from given color"""
136
- def __init__(self, color, alpha_light=0.15, alpha_dark=0.5):
136
+ def __init__(self, color, alpha_light=0.15, alpha_dark=0.7):
137
137
  """
138
138
  Parameters
139
139
  ----------
@@ -12,14 +12,10 @@ import multiprocessing as mpr
12
12
  from datetime import date
13
13
 
14
14
  import numpy as np
15
- import matplotlib as mpl
16
- if os.environ.get('DISPLAY', '') == '':
17
- mpl.use('Agg')
18
15
  import matplotlib.pyplot as plt
19
16
 
20
17
  from .fit_driver import fit
21
18
  from .mcmc_driver import mcmc
22
- from .ns_driver import nested_sampling
23
19
  from . import utils as mu
24
20
  from . import stats as ms
25
21
  from . import plots as mp
@@ -91,7 +87,6 @@ def sample(
91
87
  - 'mrw': Metropolis random walk.
92
88
  - 'demc': Differential Evolution Markov chain.
93
89
  - 'snooker': DEMC-z with snooker update.
94
- - 'dynesty': DynamicNestedSampler() sampler from dynesty.
95
90
  ncpu: Integer
96
91
  Number of processors for the MCMC chains (mc3 defaults to
97
92
  one CPU for each chain plus a CPU for the central hub).
@@ -253,16 +248,8 @@ def sample(
253
248
  >>> prior=prior, priorlow=priorlow, priorup=priorup,
254
249
  >>> leastsq='lm', nsamples=1e5, burnin=1000, plots=True)
255
250
 
256
- >>> # Nested sampling:
257
- >>> ns_output = mc3.sample(
258
- >>> data, uncert, func, params, indparams=indparams,
259
- >>> sampler='dynesty', pstep=pstep, ncpu=ncpu, pmin=pmin, pmax=pmax,
260
- >>> prior=prior, priorlow=priorlow, priorup=priorup,
261
- >>> leastsq='lm', plots=True)
262
-
263
251
  >>> # See more examples and details at:
264
252
  >>> # https://mc3.readthedocs.io/en/latest/mcmc_tutorial.html
265
- >>> # https://mc3.readthedocs.io/en/latest/ns_tutorial.html
266
253
  """
267
254
  # Logging object:
268
255
  if isinstance(log, str):
@@ -345,8 +332,6 @@ def sample(
345
332
 
346
333
  if ncpu is None and sampler in ['snooker', 'demc', 'mrw']:
347
334
  ncpu = nchains
348
- elif ncpu is None and sampler == 'dynesty':
349
- ncpu = 1
350
335
  # Cap the number of processors:
351
336
  if ncpu >= mpr.cpu_count():
352
337
  log.warning(
@@ -374,10 +359,6 @@ def sample(
374
359
  pmax = np.tile( np.inf, nparams)
375
360
  pmin = np.asarray(pmin)
376
361
  pmax = np.asarray(pmax)
377
- if (np.any(np.isinf(pmin)) or np.any(np.isinf(pmax))) \
378
- and sampler=='dynesty':
379
- log.error('Parameter space must be constrained by pmin and pmax')
380
-
381
362
  if pstep is None:
382
363
  pstep = 0.1 * np.abs(params)
383
364
  pstep = np.asarray(pstep)
@@ -428,11 +409,6 @@ def sample(
428
409
  )
429
410
  os.makedirs(fpath)
430
411
 
431
- # At the moment, skip optimization when these dynesty inputs exist:
432
- if sampler == 'dynesty' \
433
- and ('loglikelihood' in kwargs or 'prior_transform' in kwargs):
434
- leastsq = None
435
-
436
412
  # Least-squares minimization:
437
413
  chisq_factor = 1.0
438
414
  if leastsq is not None:
@@ -479,12 +455,6 @@ def sample(
479
455
  fgamma, fepsilon, hsize, kickoff, savefile, resume, log,
480
456
  pnames, texnames,
481
457
  )
482
- elif sampler == 'dynesty':
483
- output = nested_sampling(
484
- data, uncert, func, params, indparams, indparams_dict,
485
- pmin, pmax, pstep, prior, priorlow, priorup, ncpu,
486
- thinning, resume, log, **kwargs,
487
- )
488
458
 
489
459
  # Get some stats:
490
460
  output['chisq_factor'] = chisq_factor
@@ -510,7 +480,6 @@ def sample(
510
480
  posterior, pnames=texnames[ifree], theme=theme,
511
481
  bestp=bestp[ifree], statistics=statistics,
512
482
  )
513
- print(post.statistics)
514
483
  # Let Posterior to turn the theme into a Theme() object:
515
484
  theme = post.theme
516
485
 
@@ -591,13 +560,8 @@ def sample(
591
560
  log.msg("\nOutput sampler files:")
592
561
  log.msg(stats_file, indent=2)
593
562
 
594
- # Save results (pop unpickables before saving, then put back):
595
563
  if savefile is not None:
596
- unpickables = ['dynesty_sampler']
597
- unpickables = np.intersect1d(unpickables, list(output.keys()))
598
- tmp_outputs = {key: output.pop(key) for key in unpickables}
599
564
  np.savez(savefile, **output)
600
- output.update(tmp_outputs)
601
565
  log.msg(savefile, indent=2)
602
566
 
603
567
  if plots:
@@ -467,7 +467,7 @@ def cred_region(posterior=None, quantile=0.6827, pdf=None, xpdf=None):
467
467
  return pdf, xpdf, HPDmin
468
468
 
469
469
 
470
- class ppf_uniform(object):
470
+ class ppf_uniform():
471
471
  """
472
472
  Percent-point function (PPF) for a uniform function between
473
473
  pmin and pmax. Also known as inverse CDF or quantile function.
@@ -504,57 +504,75 @@ class ppf_uniform(object):
504
504
  return (self.pmax-self.pmin)*u + self.pmin
505
505
 
506
506
 
507
- class ppf_gaussian(object):
507
+ class ppf_gaussian():
508
508
  """
509
- Percent-point function (PPF) for a two-sided Gaussian function
509
+ Percent-point function (PPF) for a Gaussian distribution
510
+ (with potentially assymetric standard deviations)
510
511
  Also known as inverse CDF or quantile function.
511
512
 
512
513
  Parameters
513
514
  ----------
514
515
  loc: Float
515
516
  Center of the Gaussian function.
516
- lo: Float
517
+ sigma_lo: Float
517
518
  Left-sided standard deviation (for values x < loc).
518
- up: Float
519
+ sigma_up: Float
519
520
  Right-sided standard deviation (for values x > loc).
520
-
521
- Returns
522
- -------
523
- ppf: Callable
524
- The Gaussian's PPF.
521
+ pmin: Float
522
+ Left-sided domain boundary of the PPF.
523
+ pmax: Float
524
+ Right-sided domain boundary of the PPF.
525
525
 
526
526
  Examples
527
527
  --------
528
528
  >>> import mc3.stats as ms
529
- >>> ppf_g = ms.ppf_gaussian(0.0, 1.0, 1.0)
529
+ >>> ppf_g = ms.ppf_gaussian(2.0, 1.0, 1.0)
530
530
  >>> # The domain of the output function is (0,1):
531
- >>> print(ppf_g(1e-10), ppf_g(0.5), ppf_g(1.0-1e-10))
532
- (-6.361340902404056, 0.0, 6.361340889697422)
531
+ >>> print(ppf_g(0.5))
532
+ 2.0
533
+
534
+ >>> print(ppf_g(0.158))
535
+ 0.9972883349734507
536
+
533
537
  >>> # Also works for np.array inputs:
534
- >>> print(ppf_g(np.array([1e-10, 0.5, 1-1e-10])))
535
- [-6.3613409 0. 6.36134089]
538
+ >>> print(ppf_g(np.array([0.025, 0.158, 0.5, 0.6])))
539
+ [0.04003602 0.99728833 2. 2.2533471 ]
536
540
  """
537
- def __init__(self, loc, lo, up):
541
+ def __init__(self, loc, sigma_lo, sigma_up, pmin=-np.inf, pmax=np.inf):
538
542
  self.loc = loc
539
- self.lo = lo
540
- self.up = up
543
+ self.sigma_lo = sigma_lo
544
+ self.sigma_up = sigma_up
545
+ self.pmin = pmin
546
+ self.pmax = pmax
547
+ a = (self.pmin - self.loc) / self.sigma_lo
548
+ b = (self.pmax - self.loc) / self.sigma_up
549
+ self.rv_lo = ss.truncnorm(a, b, loc=loc, scale=sigma_lo)
550
+ if sigma_up != sigma_lo:
551
+ self.rv_up = ss.truncnorm(a, b, loc=loc, scale=sigma_up)
552
+ self.u_threshold = sigma_lo/(sigma_lo+sigma_up)
553
+ self._ufactor1 = 1.0 + sigma_up/sigma_lo
554
+ self._ufactor2 = 1.0 + sigma_lo/sigma_up
541
555
 
542
556
  def __call__(self, u):
543
- if np.isscalar(u) and u < self.lo/(self.lo+self.up):
544
- return ss.norm.ppf(0.5*u*(self.lo+self.up)/self.lo,
545
- scale=self.lo, loc=self.loc)
546
- elif np.isscalar(u):
547
- return ss.norm.ppf(1-0.5*(1-u)*(1+self.lo/self.up),
548
- scale=self.up, loc=self.loc)
549
- # else:
557
+ if self.sigma_lo == self.sigma_up:
558
+ return self.rv_lo.ppf(u)
559
+
560
+ if np.isscalar(u):
561
+ if u < self.u_threshold:
562
+ return self.rv_lo.ppf(0.5*u*self._ufactor1)
563
+ return self.rv_up.ppf(1.0-0.5*(1-u)*self._ufactor2)
564
+
550
565
  icdf = np.empty_like(u)
551
- left = u < self.lo/(self.lo+self.up)
552
- icdf[ left] = ss.norm.ppf(0.5*u[left]*(1+self.up/self.lo),
553
- scale=self.lo, loc=self.loc)
554
- icdf[~left] = ss.norm.ppf(1-0.5*(1-u[~left])*(1+self.lo/self.up),
555
- scale=self.up, loc=self.loc)
566
+ left = u < self.u_threshold
567
+ icdf[left] = self.rv_lo.ppf(0.5*u[left]*self._ufactor1)
568
+ icdf[~left] = self.rv_up.ppf(1.0-0.5*(1-u[~left])*self._ufactor2)
556
569
  return icdf
557
570
 
571
+ def draw(self, size):
572
+ u = np.random.uniform(size=size)
573
+ samples = self.__call__(u)
574
+ return samples
575
+
558
576
 
559
577
  def dwt_daub4(array, inverse=False):
560
578
  """
@@ -601,29 +619,36 @@ class Loglike(object):
601
619
  (sign of an invalid parameter set), return a large-negative
602
620
  log likelihood (to reject the sample).
603
621
  """
604
- def __init__(self, data, uncert, func, params, indp, pstep):
622
+ def __init__(self, data, uncert, func, params, args, pstep):
605
623
  self.data = data
606
624
  self.uncert = uncert
607
625
  self.func = func
608
626
  self.params = params
609
- self.indp = indp
627
+ self.args = args
610
628
  self.pstep = pstep
611
629
  self.ifree = pstep>0
612
630
  self.ishare = np.where(pstep<0)[0]
631
+
632
+ # Pre-calculate the part outside chi-square:
633
+ self._uncert_logl = -0.5*np.sum(np.log(2.0*np.pi*self.uncert**2.0))
634
+
635
+
613
636
  def __call__(self, params):
614
637
  self.params[self.ifree] = params
615
638
  for s in self.ishare:
616
639
  self.params[s] = self.params[-int(self.pstep[s])-1]
617
- model = self.func(self.params, *self.indp)
640
+
641
+ model = self.func(self.params, *self.args)
618
642
  log_like = -0.5 * np.sum(
619
643
  ((self.data - model) / self.uncert)**2.0
620
644
  )
645
+ log_like += self._uncert_logl
621
646
  if not np.isfinite(log_like):
622
647
  log_like = -1.0e98
623
648
  return log_like
624
649
 
625
650
 
626
- class Prior_transform(object):
651
+ class Prior_transform():
627
652
  """Wrapper to compute the PPF of a set of parameters."""
628
653
  def __init__(self, prior, priorlow, priorup, pmin, pmax, pstep):
629
654
  self.ppf = []
@@ -634,7 +659,7 @@ class Prior_transform(object):
634
659
  if plo == 0.0 or pup == 0.0:
635
660
  self.ppf.append(ppf_uniform(min, max))
636
661
  else:
637
- self.ppf.append(ppf_gaussian(p0, plo, pup))
662
+ self.ppf.append(ppf_gaussian(p0, plo, pup, min, max))
638
663
  def __call__(self, u):
639
664
  return [ppf(v) for ppf,v in zip(self.ppf, u)]
640
665
 
@@ -4,6 +4,6 @@
4
4
  # mc3 Version:
5
5
  MC3_VER = 3 # Major version
6
6
  MC3_MIN = 1 # Minor version
7
- MC3_REV = 2 # Revision
7
+ MC3_REV = 4 # Revision
8
8
 
9
9
  __version__ = f'{MC3_VER}.{MC3_MIN}.{MC3_REV}'
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.1
2
+ Name: mc3
3
+ Version: 3.1.4
4
+ Summary: Multi-core Markov-chain Monte Carlo package
5
+ Author-email: Patricio Cubillos <patricio.cubillos@oeaw.ac.at>
6
+ License: Copyright (c) 2015-2022 Patricio Cubillos and contributors.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Project-URL: Homepage, https://github.com/pcubillos/mc3
27
+ Requires-Python: >=3.6
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy>=1.19.5
31
+ Requires-Dist: scipy>=1.5.4
32
+ Requires-Dist: matplotlib>=3.3.4
33
+ Provides-Extra: test
34
+ Requires-Dist: pytest>=6.0; extra == "test"
35
+
36
+ # mc3: Multi-core Markov-chain Monte Carlo
37
+ > A Python implementation of the Markov-chain Monte Carlo algorithm.
38
+
39
+ [![Tests](https://github.com/pcubillos/mc3/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/pcubillos/mc3/actions/workflows/python-package.yml)
40
+ [![Documentation Status](https://readthedocs.org/projects/mc3/badge/?version=latest)](https://mc3.readthedocs.io/en/latest/?badge=latest)
41
+ [![PyPI](https://img.shields.io/pypi/v/mc3.svg)](https://pypi.org/project/mc3)
42
+ [![Conda Version](https://img.shields.io/conda/vn/conda-forge/mc3.svg)](https://anaconda.org/conda-forge/mc3)
43
+ [![GitHub](https://img.shields.io/github/license/pcubillos/mc3.svg?color=blue)](https://mc3.readthedocs.io/en/latest/license.html)
44
+
45
+ ### Install as:
46
+ ```
47
+ pip install mc3
48
+ ```
49
+ or:
50
+ ```
51
+ conda install -c conda-forge mc3
52
+ ```
53
+
54
+ ### Docs at:
55
+ <https://mc3.readthedocs.io/en/latest/>
56
+
57
+ ### Cite as:
58
+ ```bibtex
59
+ @ARTICLE{CubillosEtal2017apjRednoise,
60
+ author = {{Cubillos}, Patricio and {Harrington}, Joseph and {Loredo}, Thomas J. and {Lust}, Nate B. and {Blecic}, Jasmina and {Stemm}, Madison},
61
+ title = "{On Correlated-noise Analyses Applied to Exoplanet Light Curves}",
62
+ journal = {\aj},
63
+ keywords = {methods: statistical, planets and satellites: fundamental parameters, techniques: photometric, Astrophysics - Earth and Planetary Astrophysics},
64
+ year = 2017,
65
+ month = jan,
66
+ volume = {153},
67
+ number = {1},
68
+ eid = {3},
69
+ pages = {3},
70
+ doi = {10.3847/1538-3881/153/1/3},
71
+ archivePrefix = {arXiv},
72
+ eprint = {1610.01336},
73
+ primaryClass = {astro-ph.EP},
74
+ adsurl = {https://ui.adsabs.harvard.edu/abs/2017AJ....153....3C},
75
+ adsnote = {Provided by the SAO/NASA Astrophysics Data System}
76
+ }
77
+ ```
78
+
@@ -2,7 +2,6 @@
2
2
  CONTRIBUTING.md
3
3
  LICENSE
4
4
  MANIFEST.in
5
- Makefile
6
5
  README.md
7
6
  pyproject.toml
8
7
  pytest.ini
@@ -27,7 +26,6 @@ docs/figures/quad_pairwise.png
27
26
  docs/figures/quad_trace.png
28
27
  docs/figures/rms-vs-binsize.png
29
28
  examples/get_started.py
30
- examples/ns_tutorial.py
31
29
  examples/timeavg.py
32
30
  examples/tutorial.py
33
31
  mc3/__init__.py
@@ -35,8 +33,6 @@ mc3/__main__.py
35
33
  mc3/chain.py
36
34
  mc3/fit_driver.py
37
35
  mc3/mcmc_driver.py
38
- mc3/ns_driver.py
39
- mc3/sampler.py
40
36
  mc3/sampler_driver.py
41
37
  mc3/version.py
42
38
  mc3.egg-info/PKG-INFO
@@ -64,7 +60,6 @@ src_c/_time_averaging.c
64
60
  src_c/include/ind.h
65
61
  src_c/include/stats.h
66
62
  src_c/include/wavelet.h
67
- tests/test_dynesty.py
68
63
  tests/test_fit.py
69
64
  tests/test_logging.py
70
65
  tests/test_mcmc.py
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  mc3 = mc3.__main__:main
3
-
@@ -1,3 +1,6 @@
1
1
  numpy>=1.19.5
2
2
  scipy>=1.5.4
3
3
  matplotlib>=3.3.4
4
+
5
+ [test]
6
+ pytest>=6.0
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = [
3
+ 'setuptools>=40.8.0',
4
+ 'wheel',
5
+ 'oldest-supported-numpy',
6
+ ]
7
+ build-backend = "setuptools.build_meta"
8
+
9
+ [project]
10
+ name = "mc3"
11
+ description = "Multi-core Markov-chain Monte Carlo package"
12
+ readme = "README.md"
13
+ license = { file = "LICENSE" }
14
+
15
+ #https://packaging.python.org/en/latest/guides/single-sourcing-package-version/
16
+ dynamic = ["version"]
17
+
18
+ requires-python = ">=3.6"
19
+ authors = [
20
+ {name = "Patricio Cubillos", email = "patricio.cubillos@oeaw.ac.at"},
21
+ ]
22
+
23
+ dependencies = [
24
+ 'numpy>=1.19.5',
25
+ 'scipy>=1.5.4',
26
+ 'matplotlib>=3.3.4',
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ test = [
31
+ 'pytest>=6.0',
32
+ ]
33
+
34
+ [project.urls]
35
+ "Homepage" = "https://github.com/pcubillos/mc3"
36
+
37
+ #https://setuptools.pypa.io/en/stable/userguide/entry_point.html#console-scripts
38
+ [project.scripts]
39
+ mc3 = "mc3.__main__:main"
40
+
41
+ [tool.setuptools.dynamic]
42
+ version = {attr = "mc3.version.__version__"}
43
+
44
+ #https://setuptools.pypa.io/en/stable/userguide/package_discovery.html
45
+ [tool.setuptools.packages]
46
+ find = {namespaces = false} # Take only folders with a __init__.py file
47
+
mc3-3.1.4/setup.py ADDED
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2015-2023 Patricio Cubillos and contributors.
2
+ # mc3 is open-source software under the MIT license (see LICENSE).
3
+
4
+ import os
5
+ import re
6
+ from setuptools import setup, Extension
7
+
8
+ from numpy import get_include
9
+
10
+
11
+ # C-code source and include folders
12
+ srcdir = 'src_c/'
13
+ incdir = 'src_c/include/'
14
+
15
+ cfiles = os.listdir(srcdir)
16
+ cfiles = list(filter(lambda x: re.search('.+[.]c$', x), cfiles))
17
+ cfiles = list(filter(lambda x: not re.search('[.#].+[.]c$', x), cfiles))
18
+
19
+ inc = [get_include(), incdir]
20
+ eca = ['-O3', '-ffast-math']
21
+ ela = []
22
+
23
+ extensions = [
24
+ Extension(
25
+ 'mc3.lib.' + cfile.rstrip('.c'),
26
+ sources=[f'{srcdir}{cfile}'],
27
+ include_dirs=inc,
28
+ extra_compile_args=eca,
29
+ extra_link_args=ela,
30
+ )
31
+ for cfile in cfiles
32
+ ]
33
+
34
+
35
+ setup(
36
+ ext_modules = extensions,
37
+ include_dirs = inc,
38
+ )