Nested sampling integral on a previously obtained MCMC sample This question concerns the calculation of the evidence, or marginal likelihood, from an existing MCMC sample without having to resample. There is an exhaustive and very helpful answer here:
[Computation of the marginal likelihood from MCMC samples
I'm still not clear about nested sampling. 
Is this algorithm below right or wrong?
The question is this: Is the method below right or wrong?


*

*I have an MCMC sample with N points in parameter space. Each point has a likelihood L.

*I order the N points by increasing L. So I obtain a series of L[i] where L[i+1]>L[i]. i runs from 0 to N-1

*I calculate X[i]=(N[i]-1)/N[i] where N[i] runs from 1 to N

*I therefore obtain a column of X and a column of LX.

*I integrate LX over X to obtain the Evidence.
 A: As @Carl said, MCMC and nested sampling are quite different. You can use MCMC inside nested sampling to find new points, but in this case it is running on the prior probability distribution and rejects samples where the likelihood is below the current likelihood threshold.
So the basic steps are:

*

*obtain N live points by sampling directly from the prior

*identify lowest likelihood value of the live points Lmin, and remove it from the sample (dead point)

*replace that point by sampling from the prior, but do not accept points below Lmin (likelihood-restricted prior sampling, LRPS)

*go to 2.

I skipped the steps keeping track of the volume shrinkage (the i-th volume is $\exp(-i/N)$) and assigning weights to the dead points (the i-th dead point has weight $V_i/N \times L_i$). The dead sample give (after normalisation) a weighted posterior distribution. The normalisation is the evidence/marginal likelihood.
For the LRPS, you can use rejection sampling methods or MCMC-like step sampling methods.
Examples of efficient rejection sampling methods are MultiNest and MLFriends (animation here). Examples of efficient step sampling methods include hit-and-run sampling, slice sampling and constrained Hamiltonian Monte Carlo.
