unit of scipy fft function - scipy

I have a small confusion on units of FT. I’m looking at the first graph of (https://docs.scipy.org/doc/scipy/tutorial/fft.html) and its corresponding code above the figure. I got that x-axis refers to frequency and y-axis refers to amplitudes. What would be the unit of x-axis though?
I know it should be related to the unit of x (=np.linspace(0.0, N*T, N, endpoint=False)). So for example, suppose the unit of x is a second (s). Then what would be the unit of xf?

Related

Symmetric Regression In Stan

I have to vectors of data points (Gene expression in Tissue A and B) and I want to see, if their is any systematic bias along its magnitude (same expression of Gene X in A and B).
The idea was to build a simple regression model in stan and see how much the posterior for the slope (beta) overlaps with 1.
model {
for (n in 1:N){
y[n] ~ normal(alpha[i[n]] + beta[i[n]] * x[n], sigma[i[n]]);
}
}
However, depending on which vector is x and which is y, I get different results, where one slope is about 1 and other not (see Image, where x and y a swapped and the colored lines represents the regressions I get from the model (gray is slope 1)). As I found out, this a typical thing for regression methods like ordinary least squares, which makes sense if one value is dependent on the other. However, here there is no dependency and both vectors are "equal".
Now the question is, what would be an appropriate model to perform a symmetrical regression in stan.
Following the suggestion from LukasNeugebauer by standardizing the data first and working without an intercept, does not solve the problem.
I cheated a bit and found a solution:
When you rotate the coordinate system by 45 degrees, the new y-Axis (y') represents the information of x and y in equal amounts. Therefor, assuming a variance only on the new y-Axis involves both x and y.
x' = x*cos((pi/180)*45) + y*sin((pi/180)*45)
y' = -x*sin((pi/180)*45) + y*cos((pi/180)*45)
The above model now results in symmetric results. Where a slope of 0, represents a slope of 1 in the old system.

How to propagate error when using scipy quad on a spline of data with measurement error?

I have a data set with N points which I fit a spline to and integrate using scipy.integrate.quad. I would like to use the N associated measurement errors to put an error estimate on the final integral value.
I originally tried to use the uncertainties package but the x+/-stddev objects did not work with scipy.
def integrand(w_point, x, y):
#call spline function to get data arbitrary points
f_i = spline_flux_full(x, y, w_point)
#use spline for normalizing data at arbitrary points
f_i_continuum = coef_continuum(w_point)
#this is the integrand evaluated at w_point
W_i = 1.-(f_i/f_i_continuum)
return(W_i)
Have any ideas?
Synthetic datasets. You have your data points with errors. Now generate 1000 datasets with each point drawn from a normal distribution centered around the measured point and standard deviation given by an errror at this point. Fit each dataset. Integrate. Repeat. Now you have 1000 values of the integral. Compute the mean and std dev of these values.

Confidence intervals on the derivative of a polynomial surface

My problem is the following:
I have fit a surface to some xyz coordinate data to obtain a polynomial surface. That's a polynomial in the variables x and y giving a surface of z-values. I know how to compute 95 percent condidence intervals on the mean response and also new predicition intervals (the standard stuff). Having obtained the surface function it's also easy to determine the derivative at a certain point on the the surface however, what I'm looking for is:
How do I compute confidence levels on the derivative value dS/dx, the (partial) derivative in the x direction at a certain point?
Are there expressions for calculating such intervals similar to the intervals for the 95 percent confidence intervals on the mean response?
(Please don't bother to post an answer on the confidence interval for the slope of a simple regression line. That's not the answer to this question. Anyway, I think it isn't.)

Units for Matlab PSD

Im new to matlab and as part of my university assignment,im supposed to draw up these signals on matlab.and i have some problems regarding the units of the psd plots.
1)j=0:1/100:1; %time index
z=sin(2*pi*5*j); %sine wave signal
z=z*2;
plot(z),xlabel('Sampling Points'),ylabe;('Amplitude');
figure,psd(z)
2)noise=rand(1,100);
plot(noise);
figure,psd(noise);
3)[B,A]=butter(10,3/50,'low');
LPFz=filtfilt(B,A,z);
plot(LPFz)
figure,psd(LPFz)
4)y=wavread('sp1.wav');
Fs=44100; %sampling frequency
wavplay(y,Fs);
save sp1.mat y
plot(y(:,1)),title('Waveform of Speech'),xlabel('Sample Points'),ylabel('Amplitude')
figure,psd(y(:,1))
i would be extremely grateful to anyone who can help my by telling me the units i should use for the x axis of the psd spectrum,y axis is in dB ,that i got.i dont know what to out for x
If you are looking at your first example the x coordinate of plot (z) should be time. After all you define j as a time index and generate your z-function to be a function z(t).
If I am not mistaken your z function is a sine of structure 2*pi*omega*time with omega beeing a constant (5).
If u have further information about that constant you can be more specific about your x-axis.
As a matter of fact you can just look at your function: exponents as well as triangular functions (sine, cosine ,etc) have to be without dimension (seconds, meters ,kg, and so on)
If you were wondering about the units for the psd function, it is a spectrum. This means the x-axis is a frequency domain(1/seconds = 1Hz). In Matlab 8.2 it is recommended to use spectrum(z) instead of psd(z)

units on x axis after FFT

My signal is a static 1D pattern detected by the linear photodiode array with N pixels and pitch p.
What units will I get along the X-axis after FFT to spectrum?
If you have a signal f(x) with unit U depending on variable x with unit V. Then
the continuous Fourier transform of f has unit UV and depends on a variable with unit 1/V.
Example 1: f(x) is a Voltage with x being time. then the Fourier transform has unit Vs (or V/Hz) versus variable 1/s (or Hz).
Example 2: f(x) is a power with x being space. Then the FT has unit Wm and the x axis (which is then a wavenumber) unit 1/m (this is probably your case).
the Discrete Fourier transform (or FFT) has unit U (same as original) and depends on a discrete variable, (which has with unit 1 by definition because it is just a counter).
So the units of the X-Axis of a FFT are 1 (because it is a counter).
I included the continuous Fourier transform, because I suspect that you just confused the FFT (which is just the name of an algorithm for the discrete Fourier transform by the way) with the ordinary (continuous) Fourier transform.
Let me clarify my above question because of the shortage of initial meaningful data.
The question was related with inverse FT of a spatial interferogram (a.k.a. fringe pattern) formed from the optical radiation by a static Fourier-transform spectrometer and detected with a linear photo diode array to reconstruct finally the optical spectrum.
Therefore, the mathematically formal answer "So the units of the X-Axis of a FFT are 1 (because it is a counter)" is absolutely right.