Esempio n. 1
0
def learn(N, k, loc=3, prng=None):
    """Simulate learning behavior"""
    
    prng = process_prng(prng)
    
    trials, prng = tlib.random(N, k, prng=prng)
    trials, prng = tlib.jitter(trials, prng=prng)
    l = trials.shape[0]
    
    acc = np.zeros(l)
    p = np.zeros(l)

    conds = np.unique(trials)
    for n in conds:
        ## Skip null trials
        if (n == 0) | (n == '0'):
            continue

        p_n, prng = probability.learn(k, loc, prng=prng)
        acc_n, prng = acclib.accuracy(p_n, prng=prng)
        
        for t in enumerate(trials):
            acc[trials == n] = acc_n
            p[trials == n] = p_n

    return trials, acc, p, prng
Esempio n. 2
0
def random(N, k, prng=None):
    """Simulate random behavior
    
    Parameters
    ----------
    N : int
        Number of conditions
    k : int
        Number of trials / condition
    prng : RandomState object, None
        Explicit passing of random state.  None create
        a new state
    """
    prng = process_prng(prng)
    
    trials, prng = tlib.random(N, k, prng=prng)
    trials, prng = tlib.jitter(trials, prng=prng)
    l = trials.shape[0]
    
    acc = np.zeros(l)
    p = np.zeros(l)

    conds = np.unique(trials)
    for n in conds:
        ## Skip null trials
        if (n == 0) | (n == '0'):
            continue

        p_n, prng = probability.random(k, prng=prng)
        acc_n, prng = acclib.accuracy(p_n, prng=prng)
        
        for t in enumerate(trials):
            acc[trials == n] = acc_n
            p[trials == n] = p_n

    return trials, acc, p, prng