Mean (with confidence bands) for signals sampled at different timepoints

3 views (last 30 days)
I have ratings from multiple subjects, which I'd like to average and display with confidence bands to show cross-subject variability, more or less like in this random plot I found in some paper (where 3 separate conditions are shown):
Once I have the mean and confidence intervals at each timepoint, I figured I could then plot those either with the ciplot Exchange function, or with something like:
fill(x,y_CI, colours, 'FaceAlpha',0.2, 'LineStyle','-');
The problem is that each of my subjects' rating curve is sampled at different time points, for instance one subject might have ratings at [0.5s, 1.1s, ..], and another at [0.2s, 0.6s, ..].
I could manually define a linspace with 100ms-or-so bins and manually compute an average + CI for each. But this seems hacky, and I'm sure a more elegant & simple way exists, although I found no built-in Matlab function for it. One answer to this question suggests using defining and synchronising timetables, but this probably doesn't work in my case as the total number of ratings differs across subjects.
Any help would be greatly appreciated!
dpb on 14 Aug 2022
"Using `synchronize` with spline gave me artefactual interpolations, with y values that go way outside of the 0-100 range."
Yes, not too surprising with a spline if the data have points of inflection; the spline will fit a quadratic through each subsequent set of points -- it will go through each point identically, but is not constrained in between -- I forget whether the method matches even first derivative at the breakpoints or not; my thinking is "not".
Would have to see what particular datasets you're looking at look like to have any specific recomendations other than the obvious(?) of using 'linear' interpolation between the existing data.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!