Search results

  1. C

    Mathematica Defining a piecewise function in Mathematica

    Hello everyone. I am trying to do a 2D Shannon interpolation, but I cannot use a sinc because later on this expression goes in an optimization software that doesn't recognize it. I have defined my own version of sinc as: sincC = Piecewise[{(Sin[Pi* #]/(Pi*(#))), # >= 1}, {1 - (#^2)/6 +...
  2. C

    A Advice about interpolation

    Don't worry. In the end, I found out a way to do it using Shannon sampling in two dimensions. However, I am running in some issues, but I think they deserve their own thread
  3. C

    A Advice about interpolation

    The thing is that I cannot use piecewise interpolation, the result goes then into ampl, an optimization software (in which I am calculating the fastest route) which needs to know the value of the windspeed at all points. I need an algebraic expression of the windspeed, in this case, my f(x,y)...
  4. C

    A Advice about interpolation

    First of all, thanks for the answer. Second, my data doesn't have noise, since the data is the output of a prediction model (I don't know anything about it's internal working, only the output file), so I will try the lineal way instead. About the use of interpolation instead of the fit, I do...
  5. C

    A Advice about interpolation

    Hello everyone. I have a vector of size 300321*3; the columns are X position, Y position and recorded data; I need to find the interpolation polynomial. I have acess to mathematica, matlab and python. I have attempted to use a NonlinearModelFit in mathematica, but I cannot achieve a Rsquared...
  6. C

    I Differences between the PCA function and Karhunen-Loève expansion

    Hello everyone. I am currently using the pca function from matlab on a gaussian process. Matlab's pca offers three results. Coeff, Score and Latent. Latent are the eigenvalues of the covariance matrix, Coeff are the eigenvectors of said matrix and Score are the representation of the original...
  7. C

    Question about the PCA function

    Greetings everyone. I have generated a gaussian random process composed of 500 realizations and 501 observations. The used random variables are gaussian normal. I have then applied the pca analysis to that process (Mathwork's help). However, if I plot the histograms of the coeffs I don't find...
  8. C

    Problem with random variables in Matlab's PCA

    Hello. I have designed a Gaussian kernel as: [X,Y] = meshgrid(0:0.002:1,0:0.002:1); Z=exp((-1)*abs(X-Y)); Now, I calculate PCA: [coeffG, scoreG, latentG, tsquaredG, explainedG, muG]=pca(Z, 'Centered',false); I can rebuid the original data propperly as defined in the dcumentation...
  9. C

    I Karhunen Loeve Expansion in Matlab

    Hello everyone. I am trying to generate the KL expansion of a stochastic process. I use a Monte Carlo sampling method to generate the process, which involves two random variables and I compare it with it's theoretical mean for 50 values of time and they look quite similar. Then, I calculate the...
  10. C

    Mathematica Storing Mathematica output

    Yes, this seems to work. Thanks.
  11. C

    Mathematica Storing Mathematica output

    Hi. I want to store the output of Roots[LegendreP[3.0, x] == 0, x] as a vector. Can someone help me? Thanks
  12. C

    MATLAB How to program this in Matlab

    I think that I have it. Thanks for the help, you have helped me a big deal.
  13. C

    MATLAB How to program this in Matlab

    Hello everyone. I am trying to create a matrix in Matlab with two columns which should look like as follow: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9... 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1... Has anyone programed something like this before?
  14. C

    Unusual date format

    Hello everybody. Recently I have been given a series of archives which contain a series of measurements and the dates in which they were measured. The problem is that this format is the time which has happened in hours since 1900-01-01 at midnight. Can someone tell me how can I find out how to...
  15. C

    I Defining Legendre polynomials in (1,2)

    Indeed this checks out with the numerical model estimation. Thanks.
  16. C

    I Defining Legendre polynomials in (1,2)

    Hello everyone. The Legendre polynomials are defined between (-1 and 1) as 1, x, ½*(3x2-1), ½*(5x3-3x)... My question is how can I switch the domain to (1, 2) and how can I calculate the new polynomials. I need them to construct an estimation of a random uniform variable by chaos polynomials...
  17. C

    Mathematica Polynomial expansion from Python to Mathematica

    Hi everybody. In Python there is a library called chaospy. One useful command is cp.orth_ttr which generates a polynomial expansion, e. g. a series of orthogonal polynomials or orders zero, one, two... for a random variable e.g normal, uniform... For more information see...
  18. C

    I Weights and interpolation -- Replicating Python code with hand calculations

    Don't worry. You have already helped me a lot. Thanks
  19. C

    I Weights and interpolation -- Replicating Python code with hand calculations

    Indeed it does. Thank you. I only have one question left. Since I am working with a random variable, what shoud I use as f(x)? if I used the expected value, I would get a zero, since I am dealing with a uniform random variable.
  20. C

    I Weights and interpolation -- Replicating Python code with hand calculations

    I apologize if I haven't expressed myself propplerly. Here it is the full code: import chaospy as cp import numpy as np import odespy as od import matplotlib.pyplot as plt np.set_printoptions(threshold=1000,edgeitems=1000) def s(t, v0): return v0*t v0 = cp.Uniform(-1,1) #a = cp.Beta(2,2) #v0...
  21. C

    I Weights and interpolation -- Replicating Python code with hand calculations

    Hello everyone. I have a Python code which calculates, given a continuos uniform random variable U(-1,1), the order of a interpolation polynomial and a set of points the evolution of a function of this random variable. i.e. v0 = cp.Uniform(-1,1) t = np.linspace(0, 10, 10) order=1 . . . plt.plot...
Top