mcmc | A C++ library of Markov Chain Monte Carlo methods

 by   kthohr C++ Version: Current License: Apache-2.0

kandi X-RAY | mcmc Summary

kandi X-RAY | mcmc Summary

mcmc is a C++ library typically used in Simulation applications. mcmc has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

MCMCLib is a lightweight C++ library of Markov Chain Monte Carlo (MCMC) methods.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              mcmc has a low active ecosystem.
              It has 126 star(s) with 40 fork(s). There are 12 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 0 open issues and 7 have been closed. On average issues are closed in 321 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of mcmc is current.

            kandi-Quality Quality

              mcmc has 0 bugs and 0 code smells.

            kandi-Security Security

              mcmc has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              mcmc code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              mcmc is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              mcmc releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mcmc
            Get all kandi verified functions for this library.

            mcmc Key Features

            No Key Features are available at this moment for mcmc.

            mcmc Examples and Code Snippets

            Generate a classification signature definition .
            pythondot img1Lines of Code : 54dot img1License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def classification_signature_def(examples, classes, scores):
              """Creates classification signature from given examples and predictions.
            
              This function produces signatures intended for use with the TensorFlow Serving
              Classify API (tensorflow_servi  
            Initialize the classification output .
            pythondot img2Lines of Code : 30dot img2License : Non-SPDX (Apache License 2.0)
            copy iconCopy
            def __init__(self, scores=None, classes=None):
                """Constructor for `ClassificationOutput`.
            
                Args:
                  scores: A float `Tensor` giving scores (sometimes but not always
                      interpretable as probabilities) for each class.  May be `None`,   
            Sort the classification .
            pythondot img3Lines of Code : 29dot img3License : Permissive (MIT License)
            copy iconCopy
            def sort(self, sample: list[float]) -> None:
                    """
                    :param sample: example row to classify as P1 or P2
                    :return: None
                    >>> data = [[2.0149, 0.6192, 10.9263]]
                    >>> targets = [-1]
                    >>&  

            Community Discussions

            QUESTION

            MCMC for estimating negative binomial distribution
            Asked 2022-Jan-19 at 21:25

            I want to estimate parameters of negative binomial distribution using MCMC Metropolis-Hastings algorithm. In other words, I have sample:

            ...

            ANSWER

            Answered 2022-Jan-19 at 21:25

            Change dnorm in loglikelihood to dnbinom and fix the proposal for prob so it doesn't go outside (0,1):

            Source https://stackoverflow.com/questions/70777597

            QUESTION

            Error: package or namespace load failed for ‘rjags’
            Asked 2021-Dec-30 at 23:13

            I have a M1 Macbook Pro running OS Big Sur and just tried to install rjags and JAGS. I downloaded JAGS from https://sourceforge.net/projects/mcmc-jags/ without a problem, and ran install_packages("rjags"), but when I run library(rjags) I get this error:

            ...

            ANSWER

            Answered 2021-Dec-30 at 23:13

            See here for a similar post.

            So have you installed the correct version of JAGS on your Apple computer?

            Essentially, rjags is an R interface and it needs an installed JAGS (a back-end you mentioned) to function.

            Follow the instructions here to install JAGS on Apple computers with M1 chips.

            Also from the link above (from JAGS development team):

            A readme file is provided in the disk image - please do read it.
            If you find that rjags fails to load after installation of JAGS, make sure you have installed the Mavericks or El Capitan binary of R from CRAN. If you really need the Snow Leopard build of R (or if you compiled R yourself) you will have to compile JAGS from source.

            If you have followed the instructions above (and in the relevant README file) and are still having problems with installation of these binaries, please let us know via the JAGS discussion forum.

            PS: I would comment if I could, but I am new here and don't have enough points to do so.

            Source https://stackoverflow.com/questions/70533673

            QUESTION

            Needing advice on MCMC estimation in R
            Asked 2021-Nov-11 at 10:55

            Suppose the random variable X ∼ N(μ,σ2) distribution

            and I am given the observations x =(0.7669, 1.6709, 0.8944, 1.0321, 0.0793, 0.1033, 1.2709, 0.7798, 0.6483, 0.3256)

            Given prior distribution μ ∼ N(0, (100)^2) and σ2 ∼ Inverse − Gamma(5/2, 10/2).

            I am trying to give a MCMC estimation of the parameter.

            Here is my sample code, I am trying to use Random Walk MCMC to do the estimation, but it seems that it does not converge:

            ...

            ANSWER

            Answered 2021-Nov-11 at 10:55

            There are a few problems with the code.

            1. You calculate the log-likelihood, but ignore the log-prior. So effectively you're using a uniform prior, not the one you specified.

            2. The initial calculation of the log likelihood has parentheses in the wrong place:

            Source https://stackoverflow.com/questions/69924551

            QUESTION

            Using black box likelihood in pymc3
            Asked 2021-Nov-05 at 09:42

            I'm trying to include a black box likelihood function in a pymc3 model. This likelihood function just takes a vector of parameter values and returns the likelihood (all data is already included in the function).

            So far I've been following this guide and have modified the code as follows to accommodate the fact my model only has one parameter k.

            ...

            ANSWER

            Answered 2021-Nov-05 at 09:42

            As per the comments I checked out this thread and discovered that pm.potential really was the cleanest way to achieve black-box likelihood. Modifying the code above as follows did the trick:

            Source https://stackoverflow.com/questions/69841994

            QUESTION

            pyro: how to specify conditional distribution
            Asked 2021-Oct-06 at 21:17

            I am trying to use pyro for specifying a Bayesian network. I have a child node D which is continuous and it has three discrete nodes are parents, each with 10 possible states:

            So, I first define my discrete nodes as:

            ...

            ANSWER

            Answered 2021-Oct-06 at 21:17

            Good thing about pyro is that the model definition is very pythonic. The underlying PyTorch machinery can track dependencies for you.

            All you need is use the samples A, B and C and compute the parameters of the conditional p(D|A,B,C)

            Source https://stackoverflow.com/questions/69472294

            QUESTION

            Use of priors on hyper-parameters with SVGP model
            Asked 2021-Aug-30 at 18:18

            I wanted to use priors on hyper-parameters as in (https://gpflow.readthedocs.io/en/develop/notebooks/advanced/mcmc.html) but with an SVGP model.

            Following the steps of example 1, I got an error when I run de run_chain_fn :

            TypeError: maximum_log_likelihood_objective() missing 1 required positional argument: 'data'

            Contrary to GPR or SGPMC, the data are not an attribut of the model, they are included as external parameter.

            To avoid that problem I modified slightly SVGP class to include data as parameter (I don't care with mini-batching for now)

            ...

            ANSWER

            Answered 2021-Aug-30 at 18:18

            SVGP is a GPflow model for a variational approximation. Using MCMC on the q(u) distribution parameterised by q_mu and q_sqrt doesn't make sense (if you want to do MCMC on q(u) in a sparse approximation, use SGPMC).

            You can still put (hyper)priors on the hyperparameters in the SVGP model; gradient-based optimisation will then lead to the maximum a-posteriori (MAP) point estimate (as opposed to pure maximum likelihood).

            Source https://stackoverflow.com/questions/68984544

            QUESTION

            How to calculate errors of best value of parameters that obtained from MCMC method and observational data
            Asked 2021-Aug-08 at 20:54

            I had a model and some observational data. I used the MCMC method to obtain the best free parameters and used some coding to plot contours of 1 to 3 sigma confidence levels (as you see in the plot). I want the +/- value of sigma for each best value in any confidence level but I know that it is not symmetric. So, I didn't find the common equation of square variance useful. Is there any other way to calculate +/- errors? this is my contours

            this is what I want to get

            ...

            ANSWER

            Answered 2021-Aug-08 at 20:54

            I used np. percentile(w, [15, 85]), np. percentile(w, [5, 95]) and np. percentile(w, [0.5, 99.5]) in the final Gaussian probability and found errors for each confidence level correctly

            Source https://stackoverflow.com/questions/68678037

            QUESTION

            Generating a Matrix from a sum of Matrices
            Asked 2021-Jul-13 at 08:05

            I am trying to do MCMC methods on the inverse problem of A(u)x=b, where A is a symmetric positive definite square matrix. I was given that A can be expressed as A = A0 + Σi ui Ai. I want to check whether the ergodic average converges to the initial u. But I need to create some random matrix A satisfying the conditions to test out my MCMC function.

            Is it possible to create such a random matrix A that is of the form of A = A0 + Σi ui Ai and how can I go about it in python?

            Any help is greatly appreciated, thank you!

            ...

            ANSWER

            Answered 2021-Jul-13 at 08:05

            One way would be to generate SPD (symmetric positive definite) matrices A[0],A1,.. and positive numbers u1,.. and then sum them up

            Source https://stackoverflow.com/questions/68344944

            QUESTION

            Store Markov Chain Montecarlo simulations into dataframe and visualize it
            Asked 2021-Jun-28 at 11:26

            I'm trying to simulate the evolution of stock prices, so I decided to use a MCMC simulation (I don't know if there's a library that could help me with it though). What I intend to do is:

            1. Create a function for simulating the evolution of a stock price, given a number of parameters:
            ...

            ANSWER

            Answered 2021-Jun-25 at 16:51

            This would solve the map problem:

            Source https://stackoverflow.com/questions/68134169

            QUESTION

            Matplotlib - PDF and PNG have diferent line width
            Asked 2021-Jun-24 at 22:10

            I am having a problem when save a plot as a PDF. The lines in the plot, as you can see below are much much thicker than the ones in PNG. How do i solve that?

            I don't know if i cant place a PDF here, so i took a print screen, sorry for the quality.

            And the code i am using is this:

            ...

            ANSWER

            Answered 2021-Jun-24 at 22:10

            Did you try to save the images with another resolution, using for example dpi=600 as parameter in fig.savefig?

            Source https://stackoverflow.com/questions/68117276

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install mcmc

            The library can be installed on Unix-alike systems via the standard ./configure && make method:. The last line will install MCMCLib to /usr/local.
            -c a coverage build (used with Codecov)
            -d a 'development' build
            -g a debugging build (optimization flags set to -O0 -g)
            -h print help
            -i install path; default: current directory.
            -m specify the BLAS and Lapack libraries to link against; for example, -m "-lopenblas" or -m "-framework Accelerate"
            -o compiler optimization options; defaults to -O3 -march=native -ffp-contract=fast -flto -DARMA_NO_DEBUG
            -p enable OpenMP parallelization features (recommended)

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/kthohr/mcmc.git

          • CLI

            gh repo clone kthohr/mcmc

          • sshUrl

            git@github.com:kthohr/mcmc.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link