Thanks a lot, I had that silly error too.

On Oct 16 2010, 1:33 am, Ondrej Certik <ond...@certik.cz> wrote:
> On Fri, Oct 15, 2010 at 8:48 PM, HappyMac <youngjin.lee...@gmail.com> wrote:
> > Dear all,
>
> > I am new to SymPy and trying to learning how to use.
> > I have installed the latest SymPy (v. 0.6.7) and tried the following
> > Python script:
>
> > sympy_test.py
>
> > from sympy import Symbol
> > from math import *
>
> ^^^ Never ever use implicit imports (if possible). By writing this explicitly:
>
> from math import sqrt, exp
>
> it becomes clear, what is happening:
>
>
>
> > x = Symbol('x')
> > i = 0
> > prior = 1 / sqrt(2*pi) * exp(-1*x**2 / 2)
>
> You are using math.exp() here, so it needs a floating point number,
> but sympy doesn't know how to convert "x" to a floating point number,
> thus you get the exception below. The solution is to replace the line
>
> from math import sqrt, exp
>
> with
>
> from sympy import sqrt, exp
>
>
>
>
>
>
>
>
>
> > p = 1 / (1 + exp(-1*discriminations[i]*(x - difficulties[1])))
> > q = 1 - p
> > posterior = prior * q
> > print posterior
>
> > But, when I ran this Python code, I got the following error message:
> > Traceback (most recent call last):
> >  File "/Applications/eclipse/plugins/
> > org.python.pydev.debug_1.5.7.2010050621/pysrc/pydevd.py", line 978, in
> > <module>
> >    debugger.run(setup['file'], None, None)
> >  File "/Applications/eclipse/plugins/
> > org.python.pydev.debug_1.5.7.2010050621/pysrc/pydevd.py", line 780, in
> > run
> >    execfile(file, globals, locals) #execute the script
> >  File "/Users/yjlee/Documents/Worx/EclipseWorx/SymPyProjects/src/
> > sympy_test.py", line 44, in <module>
> >    prior = 1 / sqrt(2*pi) * exp(-1*x**2 / 2)
> >  File "/Library/Python/2.6/site-packages/sympy/core/basic.py", line
> > 2103, in __float__
> >    raise ValueError("Symbolic value, can't compute")
> > ValueError: Symbolic value, can't compute
>
> > All I was trying to do was to get a product of two functions, and I
> > could not figure out what I did wrong.
>
> > Could anyone tell me what I did wrong?
>
> Ondrej

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to