[Lign251] HW3 Q3
Tristan Davenport
trdavenp at cogsci.ucsd.edu
Sun Oct 21 16:29:26 PDT 2007
Hi, Melanie and I got the same error as Kathryn. Here's what we did:
Using the peaks in figure 1 as our values for mu.1 and mu.2, and
setting both sigma variables as square root of the standard deviation
of word.means, we then used the code you gave us in problem 3:
> mu.1 <- 6.35
> mu.2 <- 6.57
> sigma.1 <- sqrt(sd(word.means))
> sigma.2 <- sigma.1
> c<-.5
> d2norm <- function(x, mu.1, mu.2, sigma.1, sigma.2, c)
+ { c * dnorm(x,mu.1,sigma.1) + (1-c) * dnorm(x, mu.1, sigma.2)}
> lines(d2norm)
Error in as.vector(x, "double") : cannot coerce to vector
If alternatively you do plot(d2norm), you get:
> plot(d2norm)
Error in x(x) : argument "c" is missing, with no default
... even though we defined a value for "c" earlier.
In conclusion, this is frustrating.
~Tristan & Melanie
On 10/21/07, rlevy at ling.ucsd.edu <rlevy at ling.ucsd.edu> wrote:
> Hi Kate,
>
> Could you post a code snippet that gives this error?
>
> Thanks!
>
> Roger
>
> Kathryn Davidson wrote:
> > In problem 3, I have a perfectly good plot (using plot()) of the
> function that seems to estimate the histogram. However, I am really
> having problems using lines() to overlay it on top of the histogram. It
> just keeps saying:
> >
> > Error in as.vector(x, "double") : cannot coerce to vector
> >
> > So I guess my function isn't in vector format... but I can't figure out
> how to make it one. In Baayen pg. 27 I think he's answering this
> question but I can't follow what he's saying.
> > Any tips?
> > Kate
> >
> > On 10/21/07, *rlevy at ling.ucsd.edu <mailto:rlevy at ling.ucsd.edu>*
> <rlevy at ling.ucsd.edu <mailto:rlevy at ling.ucsd.edu>> wrote:
> >
> > Rebecca Colavin wrote:
> > > Okay, I give up.
> > >
> > > The graph in the question generates a distribution where the
> > probability
> >
> > > mass (=1) is contained under the curve. In short, the y axis is
> > (0,9) or
> >
> > > so .
> > >
> > > But when I try to do lines over it with a normal distribution,
> the y
> > values are probabilities. The y axis for this is (0,1).
> >
> > Hi Rebecca,
> >
> > Because the normal distribution is a continuous probability density,
> the
> > y values (for the density) are not bounded above by 1. Remember, it
> is
> > the *area under the curve* that must total 1. If the scale of the x
> axis
> > is small, p(x) can easily surpass 1.
> >
> > As an example, try:
> >
> > > x <- seq(-5,5,by=0.01)
> > > plot(x,dnorm(x,0,0.1),type="l")
> >
> > This normal density peaks around p(x) = 4.
> >
> > Using hist() with prob=T also is an estimation of density, which is
> why
> > the hist() y axis also surpasses 1.
> >
> >
> > Roger
> >
> >
> > --
> >
> > Roger Levy Email: rlevy at ucsd.edu
> > <mailto:rlevy at ucsd.edu>
> > Assistant Professor Phone: 858-534-7219
> > Department of Linguistics Fax: 858-534-4789
> > UC San Diego Web: http://ling.ucsd.edu/~rlevy
> >
> >
> >
> >
> >
> > _______________________________________________
> > Lign251 mailing list
> > Lign251 at ling.ucsd.edu <mailto:Lign251 at ling.ucsd.edu>
> > http://pidgin.ucsd.edu/mailman/listinfo/lign251
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Lign251 mailing list
> > Lign251 at ling.ucsd.edu
> > http://pidgin.ucsd.edu/mailman/listinfo/lign251
>
>
> --
>
> Roger Levy Email: rlevy at ucsd.edu
> Assistant Professor Phone: 858-534-7219
> Department of Linguistics Fax: 858-534-4789
> UC San Diego Web: http://ling.ucsd.edu/~rlevy
>
>
>
>
>
> _______________________________________________
> Lign251 mailing list
> Lign251 at ling.ucsd.edu
> http://pidgin.ucsd.edu/mailman/listinfo/lign251
>
More information about the Lign251
mailing list