I am a newbie with the sympy library, and I am having trouble to calculate 
the mean after have defined the formula:

    import sympy as sp
    import numpy as np
    sp.init_printing()
    
    mu, N, i, x_i = sp.symbols( 'mu N i x_i' )
    mu_form = sp.Eq( mu , (1/N) * sp.Sum( x_i, (i, 1, N) ) )



Now I want to define a list of values for `x_i` to actually calculate the 
mean.. I have attempted in such a way, but it does not seem to work 
properly:

    x_i_val = (1, 1, 3, 3, 2, 2, 2, 2)
    mu_val = mu_form.subs( [(x_i, x_i_val), (N, 8)] )



I am not interested in the `mean` in particular, I want to understand the 
way to calculate the result of such a formula, with a summation inside.

I did not have luck in finding a minimal example in the available tutorials 
and Googling.

(Asked on: http://stackoverflow.com/q/27209251/2741329)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/9883d304-81eb-40c0-a80b-7baf21835d90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to