---
title: 'Linguistics for Cognitive Science: Assignment 3'
author: "Felicia Saar (3818590), David-Elias Künstle (3822829)"
date: "19.11.2015"
output:
  html_document:
    fig_caption: yes
---



```{r, echo=FALSE}

library(ndl)

# create sequence of learning events
n = 1000
dat = data.frame(
  backgroundCue = rep("bird",  n),
  colorCue = c(rep("red", n/2), rep("blue", n/2))
)
set.seed(314)
dat = dat[sample(1:nrow(dat)),]
rownames(dat)=1:n
dat$category = ifelse(dat$colorCue=="red", "wug", "niz")

#put in the right format
dat$Frequency=1
dat$Cues = paste(dat$backgroundCue, dat$colorCue, sep="_")
dat$Outcomes = dat$category

```
```{r}

#rescorla wagner function -> association between "red" and "wug"
dat.rw = RescorlaWagner(dat, traceCue="red", traceOutcome="wug", random=F)
plot(dat.rw)

```
```{r}

#rescorla wagner function -> association between "bird" and "wug"
dat.bw = RescorlaWagner(dat, traceCue="bird", traceOutcome="wug", random=F)
plot(dat.bw)

```
```{r}

#rescorla wagner function -> association between "bird" and "niz"
dat.bn = RescorlaWagner(dat, traceCue="bird", traceOutcome = "niz", random = F)
plot(dat.bn)

```
```{r}

#rescorla wagner function -> association between "red" and "niz"
dat.rn = RescorlaWagner(dat, traceCue="red", traceOutcome = "niz", random = F)
plot(dat.rn)

```
```{r}

redniz = RescorlaWagner(dat, traceCue="red", traceOutcome="niz", random=F)
birdniz = RescorlaWagner(dat, traceCue="bird", traceOutcome="niz", random=F)
plot(1:n, redniz$weightvector+birdniz$weightvector, type="l")
abline(h=0)

redwug = RescorlaWagner(dat, traceCue="red", traceOutcome="wug", random=F)
birdwug = RescorlaWagner(dat, traceCue="bird", traceOutcome="wug", random=F)
plot(1:n, redwug$weightvector+birdwug$weightvector, type="l")
abline(h=1)

```
