Exemplo n.º 1
0
def biasAna(data1, data2,options):
    """ function biasAna(data1,data2,options)
 runs a short analysis to see whether two 2AFC datasets have a bias and
 whether it can be explained with a "finger bias"-> a bias in guessing """

    options = dict()
    options['borders'] = np.empty([5,2])
    options['borders'][:] = np.nan
    options['expType'] = 'YesNo'

    options['priors'] = [None]*5
    options['priors'][3] = lambda x: scipy.stats.beta.pdf(x,2,2)    
    options['borders'][2,:] = np.array([0,.1])
    options['borders'][3,:] = np.array([.11,.89])
    options['fixedPars'] = np.ones([5,1])*np.nan
    options['fixedPars'][4] = 0
    options['stepN']   = np.array([40,40,40,40,1])
    options['mbStepN'] = np.array([30,30,20,20,1])

    resAll = psignifit(np.append(data1, data2, axis=0),options)
    res1 = psignifit(data1,options)
    res2 = psignifit(data2,options)

    plot.plt.figure()
    a1 = plot.plt.axes([0.15,4.35/6,0.75,1.5/6])

    plot.plotPsych(resAll,showImediate=False)
    plot.plt.hold(True)
    
    plot.plotPsych(res1, lineColor= [1,0,0], dataColor = [1,0,0],showImediate=False)
    plot.plotPsych(res2,lineColor= [0,0,1], dataColor = [0,0,1],showImediate=False)
    plot.plt.ylim([0,1])

    a2 = plot.plt.axes([0.15,3.35/6,0.75,0.5/6])

    plot.plotMarginal(resAll,dim = 0,prior = False, CIpatch = False, lineColor = [0,0,0],showImediate=False)
    plot.plt.hold(True)
    
    plot.plotMarginal(res1,dim = 0,lineColor = [1,0,0],showImediate=False)
    plot.plotMarginal(res2,dim = 0,lineColor=[0,0,1],showImediate=False)
    a2.relim()
    a2.autoscale_view()

    a3 = plot.plt.axes([0.15,2.35/6,0.75,0.5/6])
    plot.plotMarginal(resAll,dim = 1,prior = False, CIpatch=False, lineColor = [0,0,0],showImediate=False)
    plot.plt.hold(True)

    plot.plotMarginal(res1,dim = 1,lineColor=[1,0,0],showImediate=False)
    plot.plotMarginal(res2,dim = 1,lineColor=[0,0,1],showImediate=False)
    a3.relim()
    a3.autoscale_view()

    a4 = plot.plt.axes([0.15,1.35/6,0.75,0.5/6])

    plot.plotMarginal(resAll,dim = 2, prior = False, CIpatch = False, lineColor = [0,0,0],showImediate=False)
    plot.plt.hold(True)
    
    plot.plotMarginal(res1,dim = 2, lineColor=[1,0,0],showImediate=False)
    plot.plotMarginal(res2,dim=2, lineColor=[0,0,1],showImediate=False)
    a4.relim()
    a4.autoscale_view()
    
    a5 = plot.plt.axes([0.15,0.35/6,0.75,0.5/6])

    plot.plotMarginal(resAll,dim = 3, prior = False, CIpatch = False, lineColor = [0,0,0],showImediate=False)
    plot.plt.hold(True)
    
    plot.plotMarginal(res1,dim = 3, lineColor=[1,0,0],showImediate=False)
    plot.plotMarginal(res2,dim = 3, lineColor=[0,0,1],showImediate=False)
    a5.set_xlim([0,1])
    a5.relim()
    a5.autoscale_view()
    
    plot.plt.draw()
Exemplo n.º 2
0
plotPsych(res)

'''
 You should notice that the percent correct is larger than 50 and we did 
 not measure a stimulus level clearly below threshold. Thus it might be 
 that the theshold is below our data, as it is the case actually in our 
 example.
 This is a common problem with adaptive procedures, which do not explore
 the full possible stimulus range. Then our heuristic for the prior may
 easily fail.

 You can see how the prior influences the result by looking at the
 marginal plot for the threshold as well:
'''
#plt.figure()
plotMarginal(res,0)

'''
 note that the dashed grey line, which marks the prior goes down where
 there is still posterior probability. This shows that the prior has an
 influence on the outcome. 

 To "heal" this psignifit allows you to pass another range, for which you
 believe in the assumptions of our prior. The prior will be set as for the
 true data range, but for the provided range.
 For our example dataset we might give a generous range and assume the
 possible range is .5 to 1.5 
'''
options = dict()
options['expType'] = 'equalAsymptote'