Bootstrapping using a random number generator?

In summary, the MATLAB function is using wavelet analysis and a bootstrap method to calculate mean, quantiles, and standard deviation of time-frequency wavelet coefficients for EEG data. It then uses these values to calculate a Z-score and create a mask to identify significant changes in power. It is a statistical tool for analyzing EEG data.
  • #1
Jamin2112
986
12
I've been using this MATLAB function a guy gave me to crunch numbers on some EEG data from patients. If you have any idea what it does, let me know. From what I can tell it's somehow using random numbers to calculate the probability of getting certain power values? He doesn't comment his code, which makes it harder for me to figure this out.


Code:
function [map,up,low,Z,mask]=test_stat_wavelet(x,t,fw,nb,tbase,p)
%function [map,up,low,Z,mask]=test_stat_wavelet(x,t,fw,nb,tbase,p)
fs=1/diff(t(1:2));
[C,CS,Call,C0]=time_frequency_wavelet(x,fw,fs,1,1,'CPU');
map=zeros(length(t),length(fw));
hh=waitbar(0,'testing');
for i=1:length(fw)
    ax=squeeze(Call(:,i,:));
    stat=bootstrap_mean(ax,nb);
    map(:,i)=mean(stat,1)';
    up(:,i)=quantile(stat,1-p,1)';
    low(:,i)=quantile(stat,p,1)';
    waitbar(i/length(fw));
end
close(hh);
mm=mean(map(t>tbase(1) & t<tbase(2),:),1);
s=std(map(t>tbase(1) & t<tbase(2),:),0,1);
Z=(map-ones(size(map,1),1)*mm)./(ones(size(map,1),1)*s);
mask=zeros(size(Z));
mask(low>ones(size(map,1),1)*mm)=1;

function y=bootstrap_mean(x,n)
y=zeros(n,size(x,1));fast=1;
nt=size(x,2);
yg=double(y);
xg=double(x);
ix=round(rand(n,nt)*nt);
ix(ix<1)=1;ix(ix>nt)=nt;
ix=single(ix);
if(fast)
    xgb=zeros(n,size(x,1),size(x,2));
    for k=single(1:n)
        xgb(k,:,:)=x(:,ix(k,:));
    end
    y=mean(xgb,3);
else
    for k=single(1:n)
        qx=ix(k,:);
        yg(k,:)=mean(xg(:,qx),2)';
    end
    y=double(yg);
end
 
Physics news on Phys.org
  • #2




Hi there,

From what I can tell, this MATLAB function is using wavelet analysis to analyze EEG data from patients. The function first calculates the time-frequency wavelet coefficients of the input data, and then uses a bootstrap method to calculate the mean, upper and lower quantiles, and standard deviation of these coefficients at different frequencies.

The function then uses these values to calculate a Z-score for each time point and frequency, and creates a mask based on the lower quantile to identify significant changes in power. This function seems to be a statistical tool for analyzing EEG data and identifying patterns or changes in power over time and at different frequencies.

I hope this helps, and if you have any other questions, please let me know. Best of luck with your research!
 

Related to Bootstrapping using a random number generator?

1. What is bootstrapping using a random number generator?

Bootstrapping using a random number generator is a statistical method used to estimate the sampling distribution of a statistic by generating multiple random samples from the original data set. It is commonly used in inferential statistics to make inferences about a population based on a smaller sample.

2. How does bootstrapping using a random number generator work?

In bootstrapping, a random sample is taken from the original data set with replacement, meaning that each data point has an equal chance of being selected for the sample. This process is repeated multiple times to create a distribution of the statistic of interest. This distribution can then be used to estimate the population parameter or to calculate confidence intervals.

3. What are the advantages of using bootstrapping with a random number generator?

Bootstrapping with a random number generator allows for the estimation of sampling distributions and population parameters without making assumptions about the underlying distribution of the data. It also allows for the calculation of confidence intervals, which can provide a more accurate understanding of the uncertainty surrounding a statistic.

4. Are there any limitations to using bootstrapping with a random number generator?

One limitation of bootstrapping with a random number generator is that it assumes that the original data set is representative of the population. If the data is not a good representation of the population, the results of the bootstrapping may not be accurate. Additionally, the accuracy of the results depends on the size of the original data set, with larger data sets providing more accurate results.

5. In what situations is bootstrapping with a random number generator most useful?

Bootstrapping with a random number generator is most useful when the underlying distribution of the data is unknown or non-normal. It is also useful when the sample size is small, as it allows for the estimation of population parameters without making assumptions about the data. Additionally, bootstrapping can be used for any type of data, making it a versatile tool for statistical analysis.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
2K
  • Programming and Computer Science
Replies
22
Views
4K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
518
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
930
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
3K
Back
Top