0
votes
0answers
6 views

SPSA loss function

I need a simple implementation (in Matlab) of the most basic SPSA algorithm for a friend of mine. I have found this code from J.C. Spall but I don't know where to find an implementation of an ...
1
vote
0answers
34 views

directed simple graph, all paths from node $ v_0 $ to an other node $ v $, MATLAB

consider a directed simple graph $ G=(V,E) $ with $ V=\lbrace v_0,v_1,\ldots,v_k \rbrace $ and adjacency matrix $ A=(a_{ij}) $, where $ a_{ij}=1 $ means, that there is an arc from node $ v_i $ to node ...
7
votes
1answer
132 views

Fast algorithm for approximating Eigenvalue distribution of large sparse matrix

I am interested in the eigenvalue distribution of a huge $2^{16}$x$2^{16}$ Hermitian sparse matrix with spectrum contained in $[-1,1]$. That is I don't need to know all eigenvalues exactly, but rather ...
1
vote
2answers
45 views

Could anyone explain how is this Matlab code for log likelihood of Gaussian distribution implemented?

I was implementing Expectation-maximization algorithm for gaussian mixture module. However I realized my implementation has very bad accuracy. Then I found some code on internet. It seems this ...
1
vote
1answer
28 views

Matlab create matrix without loops

I'm trying to create a Matrix in Matlab, which is dependent on 2 control variables $i$ and $n$. They are defined like this: $i=1:10$, $n=0:N-1$. Now I'm trying to define a matrix, where an entry is: ...
1
vote
0answers
523 views

Secant method in Matlab

I have done following, but I don't know how to put that function into this: ...
3
votes
5answers
213 views

Round a set to the nearest values in another set (2D), faster algorithm with Matlab

Given a set of numbers, like A={{1,2.5,3}, {4.2,7,10}}; and another set of numbers, like B={1,2,3,4,5}; Is there a fast ...
0
votes
1answer
36 views

Implement ideal line search algorithm

I have the function $f(x)=\frac {1}{2} \mathbf x^T Q \mathbf x$. I want to use the steepest descent algorithm where $Q$ is the diagonal matrix $\begin{bmatrix}1 & 0\\0 & 20\end{bmatrix}$ and ...
0
votes
0answers
77 views

Serious trouble converting algorithm to MATLAB code

I'm new to MATLAB and I'm having a really hard time converting an algorithm that I constructed, into code in MATLAB. Can anyone please help me? Here is my problem and algorithm: Romberg Integration ...
7
votes
0answers
339 views

Problem with an algorithm to $3$-colour the edges of cubic graphs

I'm currently trying to implement an algorithm to $3$-colour the edges of cubic graphs. (I want to do this with Matlab's Symbolic toolbox). After restricting to planar graphs to ensure the existence ...
0
votes
2answers
196 views

Shift interval of log-normally distributed latin hypercube samples

first of all I'm not sure if this part of StackExchange is the right one because my question is mainly on a way to implement something in MATLAB. Ok, now let me try to pack my whole question in one ...
0
votes
0answers
33 views

STINT Approximate stochastic integrals

This is a matlab code to simulate stochastic integrals: ...
0
votes
2answers
2k views

command randn(1,N) in matlab

This program is in Matlab to simulate Brownian motion Generating GBM: ...
0
votes
1answer
118 views

Is there another solution for write the algorithm by matlab?

I have an algorithm as you can see below and i wrote it with different 2 ways but it seems there are problems for both solutions.is there any alternative to write it with different way? $$X_i(k+1)= ...
0
votes
0answers
456 views

Matlab, QR with columns pivoting

Is there any sample matlab code computing QR decomposition with columns pivoting for a matrix? I do not need an internal function, I would like to know the method... Thanks for your help...
2
votes
2answers
2k views

Runge-Kutta algorithm for a given ODE system

consider the system given by: $$x'_{1}=9x_{1}+24x_{2}+5\cos t-\dfrac{1}{3}\sin t$$ $$x'_{2}=-24x_{1}-51x_{2}-9\cos t+\dfrac{1}{3}\sin t$$ with initial values $$x_{1}(0)=\dfrac{4}{3}$$ and ...
1
vote
1answer
175 views

Trying to sort the coefficients of the polynomial $(z-a)(z-b)(z-c)…(z-n)$ into a vector

So I have a factored polynomial of the form $(z-a)(z-b)(z-c)\ldots(z-n)$ for $n$ an even positive integer. Thus the coefficient of $z^k$ for $0 \le k < n$ will be the sum of all distinct $n-k$ ...
0
votes
1answer
587 views

Is there a function in MATLAB that sorts a bidimensional array?

Is there a function in MATLAB that sorts a bidimensional array? This is how I would like to sort it: The matrix: $\left(\begin{array}{c c c} 9 & 4 & 7\\ 1 & 5 & 2\\ 3 & 6 ...
1
vote
2answers
413 views

shadow simulation from buildings

is it possible to calculate shadow areas of buildings or simulate shadows of buildings in a city, using the heights of these buildings and the sun angle and azimuth? the basic light tracing concept ...