You can't index symbols, like x[1]. You need to use something like the
Indexed object to do that. Or just use a Function and use x(1)
instead.

Aaron Meurer

On Mon, Sep 9, 2013 at 10:32 AM, Mahmoud Yaser
<me.mahmoudya...@gmail.com> wrote:
> I am implementing the general `N-Grams` using `SymPy`
>
> the equation is:
> p(w1, w2, .... wn) = ∏ p(wi | wi-k, .... wi-1)
>
> the input words is tuple tuple([w1, w2, w3, ... wn])
>
> I tried to use `sympy.concrete.product.Product` with custom function that
> calculates the probability as first argument
>
> ```
> class Estimator(Function):
>     @classmethod
>     def eval(cls, token, history):
>         return "whatever"
>
> class _Segment(Function):
>     @classmethod
>     def eval(cls, statement, i, k):
>         return (statement[i], statement[i - k:i - 1])
>
> Product(Estimator(_Segment(statement, i, self._k)), (i, 1, len(statement)))
> ```
>
> and I am getting error  `indices must be integers, not Symbol`
> k=1m
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to