Il 14/03/2012 08:09, Vegard Lima ha scritto:
Hi,
On Wed, Mar 14, 2012 at 7:56 AM, Laurent<moky.m...@gmail.com> wrote:
I'm searching for a function
f(x)=1 if x in [a,b], =0 otherwise
how about using the Heaviside step function?
oh yes, of course it works. Thanks.
...
well
My residual problem is that this is extremely slow.
The following codes takes almost one second to compute each point :
#! /usr/bin/sage -python
# -*- coding: utf8 -*-
from sage.all import *
from scipy import stats
import numpy
X=stats.norm.rvs(size=300)
K=((heaviside(x+1)-heaviside(x-1))).function(x)
f = sum( [ K( (Xi-x) ) for Xi in X ] )
print f
pts=numpy.linspace(0,3)
for x in pts:
print numerical_approx(f(x=x)) # One second each !
Of course, each needs 600 calls to heaveside...
An idea to speed up the process ?
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org