How to fit Welch's window segments to a time series of variable length I'm trying to write a small Welch's PSD method in R right now, but I've had trouble finding information on how exactly the window segments are fitted to a given time series.

For instance, when the end of the time series does not fall on the end of the last window segment, what are the common ways to deal with this?

I'm assuming the time series is either truncated to perfectly fit the window segments, or zero-padded at the end so another segment can be perfectly fit.  I'm interested in what the standard method is for this.

For example, lets say I have:


A time series of 32 samples
5 window segments, each of 10 samples and 50% overlap


I can either, zero-pad my timeseries until it reaches 35 samples and fit an extra window segment in, or I can truncate my timeseries to 30 samples, which would perfectly fit 5 windows.  Which is the proper course of action here?
I don't think there is one right answer / best practice / standard method in this situation. It would depend on your application. I have seen both of those methods used (zero pad/truncate). Alternatively, you could choose a slightly different window length and/or overlap so that you don't have to truncate too many samples (or pad too many zeroes) near the end of the timeseries.