Questions tagged [numerics]

Also known as Numerical Analysis, Numerics aims to provide methods and algorithms for numerical computations.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

Log Sum Exponential Trick On Weibull Mixture [duplicate]

I am trying to evaluate the log-likelihood of a mixture of weibull distributions and am running into problems with the numerical aspect. In short, I have $M$ mixtures and want to evaluate: $$ \log \...
0
votes
0answers
8 views

how to work with dataset having single target for a multiple rows

I am a beginner in ML/DL. I have majorly worked on a single data file with each row having a target value Currently, I trying to build a CNN model for a given dataset. However, I am struggling with ...
0
votes
1answer
89 views

Neural ODEs gradient calculation for multiple time steps

I was reading the paper on Neural ODEs (here) and was wondering if anyone could offer some insight on calculation of the gradient of the loss function. If we are only considering 2 time points, $t_0,...
6
votes
3answers
600 views

log(1 - softmax(X))? [closed]

Let $\vec X$ be a vector. The $\vec V = \mathrm{logsoftmax}(\vec{X})$ function is defined as: $$v_i = \ln\left(\frac{e^{x_i}}{\sum_i e^{x_i}}\right)$$ This is provided in machine learning numerical ...
0
votes
0answers
16 views

How to overcome the numerical problem in the Schur complement to update inverse covariance

I'm using the Schur complement (d in my code below) to update a matrix inverse. Suppose that I have square inversible matrix A ...
0
votes
0answers
22 views

Time series reference - Estimating ARIMA models using the Yule-Walker equations and Durbin-Levinson algorithm

I am doing some research related to time-series analysis, and hence was trying to find some good examples of implementations of the common estimation algorithms. For example, I wanted to fit some ...
0
votes
0answers
34 views

Reference request - time series analysis book with numerical algorithms

I am working on some applications of time series, and I wanted to find a book that has the numerical algorithms or pseudocode for computing things like AR models, and ARIMA models, using nonlinear ...
1
vote
0answers
20 views

Why is my QR decomposition updating code numerically off?

I apologize if this is the wrong place for this question; there are a number of potential points of failure each of which suggest either Math StackExchange or StackOverflow or here, but since the ...
2
votes
3answers
74 views

Wrong coefficients in a polynomial fit

I am trying to fit data to a fourth-degree polynomial. I tried this in multiple programs (R, Origin Pro, SigmaPlot), all of which give me a polynomial of the form $ 40000 -2000x + 40x^2 -0.3x^3 + 0....
2
votes
2answers
145 views

Where is the error in my computation of the wrapped normal distribution density?

Let $\sigma\in(0,1)$ $$\phi(x):=\frac1{\sqrt{2\pi\sigma^2}}e^{-\frac{x^2}{2\sigma^2}}\;\;\;\text{for }x\in\mathbb R$$ and $$\psi(x):=\sum_{k\in\mathbb Z}\phi(x+k)\;\;\;\text{for }x\in\mathbb R$$ $\...
0
votes
0answers
49 views

How should I compute this proposal kernel density?

Let $d\in\mathbb N$ and $$u(x,y):=\beta+(1-\beta)\prod_{i=1}^d\psi(y_i-x_i)\;\;\;\text{for }x,y\in[0,1)^d,$$ where $\beta\in[0,1]$, $$\psi(x):=\sum_{k\in\mathbb Z}\varphi(k+x)\;\;\;\text{for }x\in(-1,...
1
vote
1answer
50 views

Algorithm for simple linear regression that is efficient and numerically stable

I'm developing an application that is fed with continuous data while older data is discarded. I'm using some algorithms to compute simple linear regression on these data with Perl. Basically that ...
0
votes
0answers
42 views

Equivalent of log sum exp trick for subtraction [duplicate]

I have two small positive real numbers $u, w$ such that $u > w$. Given $\log(u), \log(w)$ I'd like to find a numerically stable way to calculate $\log(u - w)$. One possible way of transforming the ...
1
vote
0answers
39 views

Why did the log likelihood decrease with additional parameters?

I'm trying to decide the effect of some factors on the time for an event to happen . Specifically, I am looking at how long it takes for the subject to pass a test (recognize the stimulus) when ...
7
votes
4answers
434 views

Expectation of $\ln(1 + e^x)$, where $x$ is normally distributed

I need to evaluate the following integral: $$\int_{-\infty}^\infty\mathrm d x \exp\left(-\frac{(x-\mu)^2}{2\nu}\right) \ln(1+e^x)$$ where $\mu$ is a finite real number and $\nu > 0$. This is just ...
0
votes
0answers
13 views

How do you handle large numbers that give infinity in intermediate calculations? [duplicate]

For example, say you need to calculate $\ln \left( \alpha + \beta e^x \right)$ for potentially large $x$. The value itself might be small, but since you need to calculate $e^x$ first, it produces ...
1
vote
0answers
9 views

How does the choice of norm affect the condition of a problem?

we know that for a differentiable problem, the absolute condition number is the norm of its jacobian i.e. ||J||. We also know that a well-conditioned problem typically has a small condition number. ...
0
votes
1answer
399 views

Inverse-normal CDF approximation in Excel, Python or R

I read that the implementations of Inverse-normal cumulative distribution function (CDF) /quantile / ppf in R, Python (scipy) and Excel give similar results. However, I can't find the very formulae ...
2
votes
0answers
136 views

Intuition about a coupon problem were we ask for the distribution of the unique coupons when the number of draws is fixed

Alternative viewpoint of the coupon collectors problem In the coupon collectors problem we draw from a collection of $n$ coupons, with replacement and ask the question how many draws $K$ it takes to ...
3
votes
0answers
145 views

Why is it much quicker to compute ridge regression than regular linear regression?

By my understanding, for a matrix with n samples and p features: Ridge regression using cholesky takes O(p^3) time Ordinary linear regression takes O(p^3) time Singular value decomposition if u, v ...
4
votes
1answer
216 views

How can we numerically compute the autocorrelation of a sample from a Markov chain generated by the Metropolis-Hastings algorithm?

Let $(X_n)_{n\in\mathbb N_0}$ denote a $\mathbb R^d$-valued Markov chain generated by the Metropolis-Hastings algorithm. Suppose I've run the algorithm on a computer and obtained a sample $x_0,\ldots,...
0
votes
0answers
70 views

Model failed to converge in lme4::glmer() when the a factor is centered or releveled

I'm running a mixed-effects model using glmer() function. The modeling works well with R's default dummy coding. But if I center or relevel a factor of 2 levels, the model failed to converge. I am ...
3
votes
2answers
391 views

adding a small constant to the diagonals of a matrix to stabilize

I have a large correlation matrix (110x110) with some small eigenvalues (about 20 < 0.1). It has been suggested that adding a constant (about 0.1) to the diagonals will help to stabilize the matrix....
1
vote
1answer
149 views

downsampling a kde / combining kde and histogram

I'm calculating a KDE of one parameter (y, particle density) in bins of another parameter (x, distance from the origin). At ...
1
vote
0answers
27 views

Model or numerical inaccuracy in R package distr

With the goal to have an "outlier"-aware normal distribution, I build a simple univariate mixing model of normal and uniform distributions: ...
1
vote
2answers
139 views

NUTS Drawing samples from slice sampler; how to keep bounds on log scale?

I'm currently working to adapt the No U-Turn Sampler from this paper for a model I'm working on. The No-U Turn sampler augments the typical hamiltonian system by incorporating a slice variable $u$ ...
1
vote
0answers
195 views

Bayesian Networks - Factor Graphs - Belief Propagation - Numerical stability

I am trying to do inference for a Bayesian Network with discrete probabilities. I converted the network to a factor graph and implemented the sum-product algorithm (belief propagation). My goal is ...
1
vote
0answers
110 views

Natural Splines and Smoother Matrix

In the context of smoothing splines, one can show that the Reinsch form is given by: $ \hat{y} = N (N^{T}N +\lambda \Omega)^{-1}N^{T} y = (I+ \lambda K)^{-1}y $ where (1) $K = (N^{T})^{-1}\Omega N^{-...
1
vote
0answers
130 views

Moment generating function of a Weibull distribution and root finding heavy and light tailed case

I consider the equation $M_x(v)=1+(1+\beta)\mu$ and I need to find the solution $v>0$ such that the equation is fulfilled. For this example I consider the moment generating function $M_X(v)$ of a ...
2
votes
2answers
472 views

Estimating correlation matrix using numeric likelihood maximization

I'm performing maximum likelihood estimation on jointly distributed data and I'm having some issues estimating the correlation terms. I am using an approach based on the Cholesky decomposition, but I ...
3
votes
1answer
74 views

Are analytical derivatives unambiguously superior to numerical derivatives in GMM?

I am estimating a non-linear GMM model. In both Stata and R, you need to specify the moment equations and the instruments, but there is no need need to provide analytical derivatives for the estimator ...
1
vote
0answers
93 views

Underflow when estimating marginal likelihood via bridge sampling

I try to use an iterative procedure to estimate the marginal likelihood in a Bayesian setting for model selection. In case you are interested in the specifics of bridge sampling in my application, see ...
3
votes
0answers
307 views

Optimization with/without an analytical gradient

A colleague is optimizing a function (e.g. trying to find the minimum of a function $f(x_1, x_2, \ldots)$). We know the analytical form and it is differentiable. I suggested calculating the ...
1
vote
1answer
851 views

Are mvrnorm() in MASS R package and rmvn() in mgcv R package equivalent?

I am carrying out posterior simulation with GAMs/SCAMs and was wondering if/how the rmvn() function differs in any way from the ...
1
vote
1answer
30 views

numberical implementation of linear regression with “loose variable”

I understand how to solve a linear system $X \beta = y$ the solution is $\beta = (X^{T}X)^{-1} X^{T} y$ The problem is I could have an entry $\beta_i$ where it has no exposure in $X$. i.e. $X$ has ...
3
votes
0answers
29 views

An urn problem: few red balls, many draws (with replacement)

So, this is a freshman probability problem and I am embarrassed to p[ost it, but I have been up for 35 hours and my brain is broken. I have an urn with 60,000 white balls and 6 red balls. From this ...
2
votes
0answers
66 views

Dealing with Numerical Issues from Computing Weighted Sample Covariance Matrix

I have vector-valued samples $\mathbf{x}_1, \mathbf{x}_2, \ldots, \mathbf{x}_N$ with normalized weights $w_1, \ldots, w_N$. I'm trying to compute a weighted sample covariance matrix: $$ \sum_i w_i (\...
0
votes
0answers
1k views

Formula for Inverse T-distribution

I am trying to formulate an expression to calculate the critical value of a T-distribution for a given degrees of freedom. I have done so already for the Normal Distribution by considering the TI-84 ...
5
votes
2answers
385 views

Parameter estimation without an explicit likelihood function

I have a parametric model, some data $y$, and I would like to find a maximum likelihood estimate for the model parameters $\theta$. My usual approach would be to write down the likelihood function $\...
4
votes
0answers
552 views

Choosing the basis functions in a linear regression

I have two random variables $X$ and $Y$ and I'm trying to model $\mathbb{E}[Y|X]$. To this end, I'd like to pick a collection of functions $f_1, f_2 \dots f_n : \mathbb{R} \to \mathbb{R}$ and then ...
2
votes
2answers
2k views

Deep Learning: Condition Number and Poor Conditioning

I am reading the following section of the book Deep Learning. Can you provide an intuitive explanation of the above section? I don't quite understand the statement "When this number is large, matrix ...
3
votes
0answers
121 views

Training an Artificial Neural Network with limited-memory Quasi-Newton

I would like to train a simple Artificial Neural Network implementing an algorithm of the class of limited-memory Quasi-Newton. I read the paper Modified quasi-Newton methods for training neural ...
5
votes
2answers
554 views

Why is two-sided gradient checking more accurate? [closed]

In week 5 of Andrew Ng's Machine Learning course, he gives the formulae for gradient checking: One-sided difference: $\dfrac{\partial}{\partial\Theta}J(\Theta) \approx \dfrac{J(\Theta + \epsilon) - ...
0
votes
0answers
118 views

Integral of probit likelihood

I'm currently trying to implement the Heckman method for estimating the dynamic probit panel model (Original paper can be found here). I'm trying to implement it according a paper of Stewart (2006), ...
3
votes
0answers
545 views

GMM Estimation and convergence problem

I try to minimize an unweighted moment function $G(\theta)$ given by $G(\theta) = \bar{g}(\theta)'\bar{g}(\theta) $. $g(\theta,x_i)$ contains the specified moment conditions, where we state $E(g(\...
3
votes
1answer
556 views

Moments of the truncated normal distribution (univariate) away from the mean

I need to compute the mean and variance of the truncated normal distribution. For simplicity, let us focus on a standard normal, since the general case can be reduced to this. The PDF is given by: $$...
1
vote
0answers
91 views

Is there a solution for Canonical Correlation Analysis on large sparse matrices?

I'm trying to run CCA over two views which are sparse matrices. The two views are very high dimensional (e.g. 300k, 400k) with 1m samples. CCA needs the input views to be zero mean but I won't be ...
37
votes
7answers
16k views

Why does Andrew Ng prefer to use SVD and not EIG of covariance matrix to do PCA?

I am studying PCA from Andrew Ng's Coursera course and other materials. In the Stanford NLP course cs224n's first assignment, and in the lecture video from Andrew Ng, they do singular value ...
0
votes
1answer
54 views

Distribution of infinite sum $\sum_{t=0}^{\infty} \epsilon_t r^t $

In my current statistics course we're being taught about time series, and in this context we came across sums like this: $$\sum_{t=1}^{\infty} \epsilon_t r^t \quad \epsilon_t\sim \text{WN}(0,\sigma^2) ...
0
votes
1answer
355 views

Method to compute empirical derivative about some point

I have black-box access to some function and I want to compute the derivative about the point X. Is there a method that does this?