Questions tagged [numerical-integration]
A class of algorithms to approximate definite integrals.
162
questions
1
vote
1
answer
49
views
Calculation of Posterior distribution numerically
For calculating posterior probabilities numerically, I did not understand that why is in the following codes they have divided by 0.001 in the denominator to calculate ...
0
votes
0
answers
13
views
Integrating splines over a set of cells
Let $f(s) = \sum_{i=1}^p \beta_i \phi_i(s)$ such that $f: \mathbb{R}^2 \mapsto \mathbb{R}_+$ and the $\phi_i$ are splines (B-splines or Thin-plate splines) and suppose we are interested in $W\subset ...
1
vote
0
answers
66
views
Maximum simulated likelihood estimation in R - binary logit example
Very often the likelihood function involves an integral which does not have a closed-form solution (e.g., random coefficients, latent variables). In these cases, we can employ monte-carlo simulation ...
1
vote
1
answer
38
views
Best way or rules of thumbs for evaluating 1d integrals from randomly sampled grid points
I have a 1D domain (let's say the interval $(0,1)$) on which I randomly sample $N$ points from the uniform distribution. I have a function $f\colon (0,1) \to \mathbb{R}$ which is integrable.
What is ...
1
vote
1
answer
45
views
MLE for parametric binomial model
I have a model in which $p_i=f(\theta,Z_i)$, where $Z_i$ are iid latent variables distributed with CDF $F_\theta$, and $d_i\sim B(n_i,p_i)$, where $B$ is the binomial distribution. The likelihood ...
0
votes
0
answers
10
views
When to stop MCMC within collapsed Gibbs?
I am setting up a Hierarchical model whose target distribution is $p(\theta,w|y)$, $\theta$ being a reduced set of high-level parameters, $w$ being a data augmentation of very high dimension, and $y$ ...
0
votes
0
answers
27
views
How to numerically get expectation of a non-linear function of a normally distributed random variable
I'm trying to calculate the expectation of the following numerically:
$$\mathbb{E}[V(\theta)]$$ where $\theta\sim N(\mu,\sigma^2)$ and $V(\theta)$ is strictly increasing.
I'm struggling to understand ...
1
vote
1
answer
34
views
How to use control variate method to estimate $\theta = \int_{1}^{\infty}\frac{x^2}{\sqrt{2\pi}}e^{-x^2/2}dx$
This is the target I want to integrate with Monte Carlo with control variate method:
$$\theta = \int_{1}^{\infty}\frac{x^2}{\sqrt{2\pi}}e^{-x^2/2}dx$$
I have checked with Wolfram that it is 0.400626, ...
4
votes
1
answer
180
views
Unbiased estimator of an integral raised to a power
I'd like to estimate an integral of the following form using Monte Carlo method:
$$ \int_{t_1}^{t_2} g(t) \left[ \int_{- \infty}^{\infty} f(t, u) du \right] ^\gamma dt$$
In case of $\gamma$ being a ...
3
votes
3
answers
317
views
How to use self-normalized importance sampling method to estimate $\int_{1}^{\infty} \frac{x^2}{\sqrt{2\pi}}e^{\frac{-x^2}{2}}dx$?
I want to use self-normalized importance sampling methods to estimate $$\int_{1}^{\infty} \frac{x^2}{\sqrt{2\pi}}e^{\frac{-x^2}{2}} \,dx$$ I choose exponential distribution with rate $\lambda=1$ as ...
1
vote
1
answer
28
views
Numerical integration over a Random Forest Regression Model
I am trying to compare the accuracy of a polynomial model and a Random forest regression model in predicting a variable Y but also the integral of this variable ,
With the polynomial model, it is ...
0
votes
0
answers
31
views
Quantiles of the posterior predictive distribution of a Gumbel random variable under the degenerate prior $\pi(\mu,\sigma) = \sigma^{-1}$
I need to find an automatic way to calculate with good precision the quantile of the posterior predictive distribution (ppd) of a random variable following a Gumbel law, under the degenerate prior $\...
0
votes
1
answer
79
views
Estimating the integral $\int_{0}^\infty x^4 e^{-2x}\,dx$
We have been given a random variable having a Gamma distribution as shown below:
Using the accept-reject algorithm, we are supposed to sample from the Gamma distribution using exponential as the ...
5
votes
1
answer
191
views
How to Find PDF of Transformed Random Variables Numerically?
Is there a way to compute and plot the transformed random variable in Python or R?
Let's say if $X_1$ and $X_2$ are independent and identically distributed random variable with PDF defined over non-...
1
vote
1
answer
71
views
Are discrete mixtures Gauss quadrature-like integral approximations?
I noticed that the formula for Gauss (or Newton-Cotes) quadrature looks very similar to the formula for the PDF of a general mixture distribution.
Let $p_{comp}(x)$ be the PDF of a compound ...
0
votes
3
answers
173
views
Why not just run a Markov chain to get stationary probabilities?
I'm reading Performance Modeling and Design of Computer Systems which contains some analysis of Markov chains. In particular, it emphasises various analytical methods for finding the stationary ...
2
votes
1
answer
917
views
Estimating the cumulative probability of a bivariate normal distribution
I have a quick question regarding working out the probabilities of a bivariate normal distribution. To my knowledge, there is no nice closed-form for a cumulative distribution function for the ...
2
votes
1
answer
111
views
Bayesian Quadrature to find expectation of unkown function w.r.t. known pdf
I am interested in estimating the integral $\int f(x) P(x) dx$, where $f(x)$ is an expensive function and $P(x)$ is has an analytic form. I would like to evaluate this with as few evaluations of $f(x)$...
4
votes
1
answer
108
views
Approximate Posterior Predictive Quantiles with Numerical Methods
I have a posterior function which is easy to approximate using numerical methods (the posterior has only 2 parameters, and is approximately Gaussian because of the large sample). However, I need to ...
1
vote
0
answers
93
views
Conditional expectation of a normal variable given a lower bound [duplicate]
I saw the identity below but I'm not sure how to derive it.
$$E[X\mid X>K] = \mu + \sigma \frac{\phi(z)}{\Phi(-z)} \text{ where } z = \frac{K-\mu} \sigma$$
I'm stuck at the following step:
$$E[X\...
3
votes
1
answer
279
views
Gompertz-Makeham Model Life Expectancy using Numerical Integration and Analytical Solution of Castellares et al. (2020)
I am trying to calculate life expectancies for the Gompertz-Makeham model, but can't replicate the results of the paper which gives the formulas. I use R to ...
4
votes
2
answers
482
views
How to calculate Quasi-Monte Carlo integration error when sampling with Sobol's sequence?
My understanding is that QMC integration using random sampling will converge with $O(\frac{1}{\sqrt{n}})$, while using Sobol's sampling will converge with $O(\frac{(\log{n})^d}{n})$. However I'm ...
12
votes
5
answers
1k
views
Estimate the Euler–Mascheroni constant ($\gamma$) by Monte Carlo simulations
The Euler–Mascheroni constant is defined simply as the limiting difference between harmonic series and the natural logarithm.
$$\gamma =\lim_{n\to \infty}\left(\sum _{k=1}^{n}{\frac {1}{k}}-\ln n\...
1
vote
0
answers
25
views
What is the expectation of a random variable satisfying some conditions?
How to find the expectation E[X.I(Y<x,X<x)], where X and Y are independent random variables with respective cumulative distribution functions F(.) and G(.) respectively. x is a positive value. ...
11
votes
2
answers
926
views
Plain English explanation of Ito's integral?
I'm looking for a plain English explanation of Ito's integral. I don't need an exhaustive proof, derivation, etc. Just a simple ~this is effectively what it does and why it's better than a Riemann sum ...
3
votes
1
answer
85
views
Numerically integrate gaussian pdf
Suppose I want to numerically integrate the function $g(\mathbf{x}) = \exp\bigg(-\frac12 \mathbf{x}^\mathsf{T}\mathbf{\Lambda} \mathbf{x}\,\bigg)$ to obtain the normalization constant
$$\int_{\mathcal{...
3
votes
1
answer
747
views
Kullback–Leibler divergence between multivariate t and the multivariate normal?
I want to calculate the Kullback–Leibler divergence between a multivariate $t$ distribution and a multivariate normal distribution, for different values of the degrees of freedom $\nu$.
However, this ...
2
votes
0
answers
125
views
Numerical integration of the exact distribution of the product of two random gaussian variables
I am trying to implement this function in R, which is equation (2) in this paper by Cui et al. (2016), which is the exact distribution of the product of two random gaussian variables.
...
1
vote
0
answers
19
views
How do mixed models bypass the overflow inside the integration?
In a mixel model, when you try to maximize the likelihood, you have to integrate over the random effects.
This means that you cannot take logs, since what would normally be a product of individual ...
1
vote
1
answer
94
views
Computing the probability $P(\exists X\in\{X_1,\ldots, X_N\}:X>\text{max}\{Y_1,\ldots, Y_M\})$
I am trying to somewhat generalize a question, which has been asked in one way or another a several times here on StackExchange**. However, I have not managed to find an answer to the below problem.
...
3
votes
1
answer
614
views
How to calculate confidence intervals for a generic (non-normal) pdf
In particular, this is a question about distributions with some skew and/or where the mean, median and mode might all be different.
For any pdf, it's possible to find multiple different domains within ...
0
votes
1
answer
876
views
Different estimates for mixed effects Logistic regression and pwrssUpdate Error message with binomial glmer
Hi this is my first post here. I reported an issue on Github and got valuable help from Dr. Bolker. However, I did some other analyses on the same data and got confused about some of the results. I ...
0
votes
0
answers
48
views
Discrete correlation function (sample cross-covariance)
The continuous correlation function for the random variable $A(t)$ at a instant of time $t$ is given by
\begin{equation}
C_{AA}(\tau) =\frac{1}{T} \int_{0}^T d\bar{t} A(\bar{t})A(\bar{t}+\tau)
\end{...
-3
votes
1
answer
92
views
Positive or negatively bounded CDFs [closed]
If $X\in\mathbb{R}^n$ is a continuous random variable whose cumulative distribution function is ordinarily
$$F_X(x) = \int_{-\infty}^{\infty} f_X(x) dx $$
what is the meaning of
$$F_X(x) = \int_{0}^{\...
7
votes
1
answer
295
views
Expressing a marginal probability using copulas
Please correct me if I am wrong and kindly provide me with the correct notations. I have two questions:
We know that for the variables $(X,Y,Z)\in \mathbb{R}^3$, the marginal joint density $f(x,y)$ ...
1
vote
0
answers
41
views
How to calculate Integral error from MCMC
I've recently started using Markov Chain Monte Carlo to calculate integrals, but I can't seem to find how to calculate the error for such an integral. In the standard case of importance sampling, the ...
1
vote
1
answer
369
views
Computational Complexity of Multivariate Normal CDF
I'm going to post this here also as per user suggestions since I feel like the root cause of the issue is more maths related than code related.
I'm working on a multivariate cross-entropy minimization ...
1
vote
1
answer
139
views
Finding confidence interval for unimodal function equivalent to and comparable with standard deviation of normal
I'm trying to characterise an arbitrary, unimodal distribution in a way that is a) easily understandable (to a physics audience) and b) comparable with a normal distribution.
My thinking goes like ...
3
votes
1
answer
227
views
Numerical integration with measurement errors: what scheme to use?
I have an unknown 'smooth' function that is sampled at some $n$ equally spaced locations $x_i$ between $0$ and $1$, with some measurement values $f(x_i)=y_i$, but each has some Gaussian uncertainty ($(...
1
vote
1
answer
301
views
Calculating variance of MC estimator of an integral
Let
$$
f(x) = \sqrt{1-x^2}, \quad I = \int \limits_0^1 f(x) dx.
$$
We consider the following estimator of I:
$$
\hat{I}_n = \frac{1}{n} \sum \limits_{i=1}^n f(X_i),
$$
where $X_1, X_2, ...$ are iid $...
0
votes
1
answer
60
views
Why are my sampled values are non Gaussian?
I just have a quick question regarding Importance Sampling Monte Carlo integration. If I sample from some pdf, $p(x,y)$, to calculate an integral. I.e., $I = \int f(x,y) \ dx\ dy$
It can be ...
1
vote
1
answer
645
views
Integration with accept reject sampling Monte Carlo
I've got a quick question with regards to accept-reject Monte Carlo integration that I can't solve. Suppose I want to integrate some function, $f(x,y)$, with samples of $x, y$ from $p(x,y)$.
Now, ...
3
votes
1
answer
152
views
How to calculate individual moments of a 2-dimensional distribution via Monte Carlo Integration
I've recently been using Monte Carlo integration to calculate a particular integrals which I can do fine but I've hit a problem where I can't calculate the individual moments of my distribution for ...
1
vote
1
answer
21
views
how do you find the vector that minimizes [closed]
How do you find the vector that minimizes $\|A\mathbf{x}-\mathbf{b}\|_2^2$ ?
3
votes
0
answers
246
views
Uncertainty propagation in ODEs
I want to see the effect of parameter uncertainty in the Euler method for ODEs.
For a differential equation:
$dx/dt=f$
with initial condition $x(0)=xo$ and a function $f$ (that has uncertain ...
1
vote
1
answer
212
views
Relatively fast approximations to the marginal likelihood?
Let $\theta\in{\mathbb R}^d$ be a multidimensional parameters, where $d$ can be large (e.g. $d=100$ or more). What approximations can I use for the marginal likelihood:
$$\int f(x\mid \theta)\pi(\...
0
votes
0
answers
217
views
Minimize asymptotic variance of fintely many estimates
Let
$(E,\mathcal E,\lambda)$ be a $\sigma$-finite measure space;
$f:E\to[0,\infty)^3$ be a bounded function with integrable Euclidean norm on $(E,\mathcal E,\lambda)$ and $p:=\alpha_1f_1+\alpha_2f_2+\...
2
votes
0
answers
34
views
Examples for integration estimator
suppose I'm interested in estimating $C=\int_{a}^{b}g(x)dx$, where $a$ and $b$ are known, and $g(x)=E(Y|X=x)$ is an unknown function of $x$. The data I have is $\{Y_{i},X_{i}\}_{i=1}^{n}$, then a ...
1
vote
0
answers
111
views
Compute which of a finite number of integrals is minimal (not interested in the actual value of the integral)
Let
$(E,\mathcal E,\lambda)$ be a $\sigma$-finite measure space;
$f:E\to[0,\infty)^3$ be a bounded Bochner integrable function on $(E,\mathcal E,\lambda)$ and $p:=\alpha_1f_1+\alpha_2f_2+\alpha_3f_3$ ...
0
votes
0
answers
28
views
multi-dim monte carlo integration -- some complicated integration
I want to integrate
$$I= \int^1_0 \int^1_0 \frac{g(x,y)}{\int^1_0 h(x,y)\,dx} \,dx\,dy. $$
For now, I sampled $n \times n$ simulation samples from $unif[0,1]$ and estimate
$$\hat{I} = n^{-2}\sum_{j}...