StringFunction with array data

1 view
Skip to first unread message

chu-ching huang

unread,
Jun 10, 2010, 8:09:49 AM6/10/10
to scitools
Hi,

> Suppose that
> t=linspace(0,1,11)
> h=StringFunction('x')


Then h is a array. But if

> h=StringFunction('0')
> h(t)

returns only one '0' but not array. Is it a feature or an bug?

Best regards,

chu-ching huang

Math Group, CGE, Chang-gunh University, Taiwan



chu-ching huang

unread,
Jun 20, 2010, 10:41:59 PM6/20/10
to scitools
More details about this problem. I want to create a function to
simulate the solution:


PDE:
\frac{d\phi}{d t} = a(x) \frac{d\phi}{d x}+\frac{b^2}
{2}\frac{d^2\phi}{d x^2}+c\phi
IC:
\phi(0,x) = h(x)

The solution is
\phi(t,x)=E^x[h(X_t)exp{int_0^t c(X_s) ds}

where E means the expectation.

StringFunction is used to pass the variables: a ,b and c which can be
constants or functions of x. And now I use the following way to
solve the problem:

>>> e = numpy.ones(Expnum,float) # create ones array
>>> c = StringFunction(c)
>>> ...
>>> I = e*c(Xt)*dt


Thanks all,
Reply all
Reply to author
Forward
0 new messages