8
votes
Polynomial approximation
$\mathbf{A}$ is an $(n+1) \times (n+1)$ matrix. It can be obtained as follows:
$\textbf{A} = \left[ \matrix{1 & 1 & 1 & \cdots & 1 \cr
x_0 & x_1 & x_2 & \...
6
votes
Accepted
Python: What is a good way to generate a 1D particle field with a gaussian distribution?
This doesn't randomly sample points, but instead chooses representative points deterministically.
scipy.stats.norm.ppf(np.linspace(0, 1, 1000+2)[1:-1])
6
votes
Accepted
Tikhonov (Ridge) Regression and Normalization
It's a question of how you choose $\lambda$ and $\Gamma$ (of course). Think for a moment about what happens if you choose $\Gamma=I$ and make $\lambda$ large: in that case you say that it is more ...
5
votes
Accepted
Data for Tracy-Widom distribution
It's actually not all that complicated to calculate the Tracy-Widom CDF just from its definition: see On The Numerical Evaluation Of Fredholm Determinants by Folkmar Bornemann. The Wikipedia page ...
5
votes
Accepted
Computing square root of diag(u)-uu'?
Would a decomposition of the form $A = XX^T$ suffice? This would be enough, e.g., if the end goal is sampling from the Gaussian distribution with this given covariance.
If so, you can use the ...
4
votes
Is there a relationship between the covariance matrix and the partial derivative?
Let $\mathbf{\theta}$ be a Gaussian random vector with mean $\mathbf{\mu}$ and covariance matrix $\mathbf{\Sigma}_\mathbf{\theta}$. Let $\mathbf{p}_\theta$ denote the joint PDF.
Let $J_\mathbf{\...
4
votes
Accepted
Polynomial approximation
You can easily do this with for loops. Just use n to define your loop limits. Here's a fully functional solution for MATLAB (just define n and x first):
...
4
votes
How to define a dimensionless Objective function for determining how peaked a curve is?
Let $f(\omega)$ be your power spectrum. Then maybe something like
$$
\frac{\|f\|_{L^\infty}\|f\|_{L^0}}{\|f\|_{L^1}} = \frac{\mathrm{max}_{\omega\in\Omega} f(\omega)\cdot|\omega_{max}-\omega_{min}|}{\...
3
votes
Accepted
Sum over very small exponentials: Underflow
You may use Kahan summation algorithm [1]
The idea is to reschedule the sum operations in such a way precision loss is limited. The code is very simple (reproduced from [1] below).
If this does not ...
3
votes
Accepted
What is "SOLVER" in R and Statistics/Analytics?
Generally, people refer to software packages as 'solver' that, well, solve some class of equations. For example, it could be stated that R contains a linear system solver.
3
votes
Data for Tracy-Widom distribution
Mathematica has the TW distributions:
http://reference.wolfram.com/language/ref/TracyWidomDistribution.html
3
votes
Accepted
Verifying that ODE integration generates Theoretical Stationary distribution
In general, your type of question would be called a "multivariate goodness of fit test". If $F(x_1,\ldots,x_n)$ is the $n$-dimensional CDF for the theoretical distribution, and the random variables $(...
3
votes
Accepted
Reconstructing statistics of $x\otimes y$ from E[XX'], E[YY'] and E[XY']
(Converted to an answer from my comments and expanded.)
Basically you need to compute the fourth moments $E[x_i x_j y_k y_l]$ for all $i,j,k,l$, given the second moments. These fourth moments are not ...
2
votes
What is the algorithm that matlab used in its built-in function 'pca'?
Principal Components Analysis (PCA) is conducted using a Singular Value Decomposition (SVD) algorithm. As Bill Barth says above, the choice of sign of the principal component vectors is entirely ...
2
votes
Python: What is a good way to generate a 1D particle field with a gaussian distribution?
NumPy comes with a nifty random library with various distributions, including normal (Gaussian).
From the Numpy documentation:
...
2
votes
Calculating AIC (in R or any other statistical software)
The AIC function need an 'lm' or 'glm' object (linear models).
See functions lm and glm
So just do : ...
2
votes
Statistical analysis of optimization algorithms
Established methodologies for benchmarking optimization software can be found in publications such as Benchmarking Optimization Software with Performance Profiles, Benchmarking Derivative-Free ...
2
votes
Force a line through the origin
I think that what you are trying to do is to find a line passing through a set of data which is able to best fit that set of data. A Least Square approach, for instance, could be used for this purpose....
2
votes
Normalize data so that the sum of squares = 1
It's not entirely clear to me what step you struggle with. But for the sake of explanation, assume you have data $x_i, i=1...N$ and you want to compute the normalized data $y_i, i=1...N$ from the $x_i$...
2
votes
Sum over very small exponentials: Underflow
You are adding positive terms, so you don't need to worry about the imprecision of the final result as if you had negative terms: (10^100+5)-(10^100+3)=2 but (10^100+5)+(10^100+3)=2*10^100 (as long ...
2
votes
How are the outcomes that generated from different predictive models combined to get more accurate predictions?
Bagging, Boosting, and Bayesian Model Averaging/Combination are all widely used techniques for doing this. These are discussed in many textbooks on machine learning.
2
votes
Accepted
Which statistical method should I use for comparing machine run-time of two algorithms?
This is a typical use case for a paired t-test. The idea is to consider only the runtime difference $\Delta t$ for each problem and test for the null hypothesis $E(\Delta t)=0$. For a step-by-step ...
2
votes
Best way to convert a sparse (containing zeros) covariance matrix into a correlation matrix?
What about the following?
Dinv = np.diag(1.0 / np.sqrt(np.diag(cov_matrix)))
corr = Dinv @ cov_matrix @ Dinv
The above avoids any division except by the diagonal ...
2
votes
SciPy ODR "Ordinary" Least Squares?
Based on the ODRPACK Documentation it seems clear that by "ordinary least squares", the authors mean least squares in which the errors are (considered to be) only in the dependent variables, ...
1
vote
Accepted
Legendre expansion of $r(x) = f(x)/g(x)$ using a finite number of samples from $f(x)$ and $g(x)$
I believe you are asking how to compute
$$\frac{f(x)}{g(x)}\approx\sum_{n=0}^p a_n P_n(x).$$
You could interpolate your samples of $f$ and $g$ to a uniform grid on $[-1,1]$, calculate the ratios at ...
1
vote
Data Analysis - Cooling Efficiency
An efficiency metric
You could use,
$$\eta = p_{\text{out}}/p_{\text{in}}$$
where the power out ($p_{\text{out}}$) is defined as the heat per second from the room to the environment, and, power in (...
1
vote
Accepted
Parameter identification for regression model
You can just write it as a least squares minimization problem. That leads to a quadratic problem that is easy to solve.
The problem is, in general, underdetermined since you only have $Nn$ equations, ...
1
vote
Accepted
Using physical parameter as a Gaussian random variable in a simple Poisson problem
In the loop over your instances of 100 random values for $k$, you could write the value for $k$ into a file, and call your finite element code; the finite element code could then open the file, read ...
1
vote
Optimize custom probability distribution in Python
Mathematically, the probability density function ($\operatorname{PDF}$) for $Z$ is given by the integral:
$$\operatorname{PDF}(Z) = \int \delta\left(Z - f_a(X,Y)\right) \operatorname{PDF}(X,Y)\...
1
vote
How are the outcomes that generated from different predictive models combined to get more accurate predictions?
Provided you have raw data you could use in this process, one could use the various different models and treat them as basis functions of sorts that you wish to merge together in a least square sense. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
statistics × 97linear-algebra × 10
data-analysis × 10
probability × 10
optimization × 9
python × 9
algorithms × 9
regression × 8
numerics × 6
machine-learning × 6
random-number-generation × 6
matlab × 5
fluid-dynamics × 5
matrix × 4
simulation × 4
computational-physics × 3
c++ × 3
performance × 3
monte-carlo × 3
eigensystem × 2
error-estimation × 2
floating-point × 2
visualization × 2
matrix-factorization × 2
molecular-dynamics × 2