%gaussianchanneldetection.m
function [pd_expected,pf_expected,pd_obtained,pf_obtained]=...
gaussianchanneldetection(x,y,len,p0,sigma,pfa,level0,level1)
%1 is represented as +5 and 0 is represented as -5. It is added with the
%gaussian noise with mean zero and variance ’var’.
%p0 is the prior probabilty of 0 in the transmitter.
%x->[c01 c10];
%y->1:Bayes technique.
%y->2:Mini-max technique
%y->3:Neyman-pearson technique
%p0->prior probability
%sigma->standard deviation of the gaussian noise
%level0 ->amplitude that represents the data 0
%level1 ->amplitude that represents the data 1
%pfa->desired probability of false alarm such that probability of
%detection is maximized in the case of Neyman-pearson technique.
%We assume one sample for each binary data
%Generation of binary sequence with antipodal representation and
%with the required prior probability p0.
data=[]; tx=[];
for i=1:1:len
temp=[p0 1];
r=temp-rand;
[val,pos]=find(r>=0);
switch pos(1)
case 1
data=[data 0];
tx=[tx level0];
case 2
data=[data 1];
tx=[tx level1];
end
end
