Пример #1
0
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 12 15:51:47 2013

@author: guille
"""

import numpy as np
import mlds

## definition of stimulus values
stim = np.linspace(0.0, 1.0, 11)

## generating quadruples
quads, indxq, invordq = mlds.generate_quadruples(stim)

## generating triads
triads, indxt, invordt = mlds.generate_triads(stim)

# EOF
Пример #2
0
def simulateobserver(func, sigma, stim, nblocks=1, gamma=1):
    """ Simulate an observer responding according to a function
    
    """
    
    ## Simulation triads experiment
    triads, indxt, order = mlds.generate_triads(stim)   

    ## where to save the results
    filename = str(uuid.uuid4()) + '.csv'
    rfl = open( filename, 'wb')
    writer = csv.writer(rfl, delimiter=' ')
    writer.writerow(['Trial', 'Response', 's1', 's2', 's3', 'invord', 'i1', 'i2', 'i3'])
    
    # going through every trial
    for b in range(nblocks):
        for t in range( len(triads) ):
            
            # slants of current triad
            if order[t]==1:
                s1 = triads[t][2]
                s2 = triads[t][1]
                s3 = triads[t][0]
            else:
                s1 = triads[t][0]
                s2 = triads[t][1]
                s3 = triads[t][2]
            
            # get mean response 
            v1 = func(s1, gamma)
            v2 = func(s2, gamma)
            v3 = func(s3, gamma)
            
    
            # responses from cue
            # random.gauss accepts negative sigmas, it probably gets 
            # the absolute number. np.random.gauss, instead, doesnt, 
            # gives an error.. This could be problematic for unconstrained 
            # optimization routines that take sigma as parameter
  
            f1 =  random.gauss( v1, sigma) 
            f2 =  random.gauss( v2, sigma)
            # if we used the same value of f2, apparently introduces correlation and scale noise estimation (sigma) is lower     
            #f2b = f2
            # we should then sample twice for the value of stimulus 2, so variances are as predicted.
            f2b = random.gauss( v2, sigma)   
            f3 =  random.gauss( v3, sigma)    
             
            # decision variable
            delta = (f3 - f2b) - (f2-f1) 
            #delta = (v3 - v2)  - (v2 -v1) + random.gauss(0, sigma)
            
            if delta>0:
                response=1
            elif delta<0:
                response=0
            else:
                response=None
                print "None"
            
            if order[t]==1:
                response = int(not response)
            writer.writerow([t, response, "%.2f" % triads[t][0], "%.2f" % triads[t][1], "%.2f" % triads[t][2], order[t], indxt[t][0]+1, indxt[t][1]+1, indxt[t][2]+1])
             
    rfl.close()

    return filename
Пример #3
0
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 12 15:51:47 2013

@author: guille
"""


import numpy as np
# appends directory where mlds.py is, and imports
import sys
sys.path.append("../")
import mlds


## definition of stimulus values
stim = np.linspace(0.0, 1.0, 11)


## generating quadruples
quads, indx, topbot = mlds.generate_quadruples(stim)


## generating triads
triads, indxt, topbot = mlds.generate_triads(stim)


# EOF