[SciPy-User] Porting matlab's ksdensity to scipy

josef.pktd@gmai... josef.pktd@gmai...
Wed Aug 4 20:11:21 CDT 2010


On Mon, Jul 19, 2010 at 12:20 PM, Tadas Vilkeliskis
<vilkeliskis.t@gmail.com> wrote:
> Hi guys!
>
> I am trying to port the code written in matlab to python and I got
> stuck with matlab's ksdensity function. The matlab code I have looks
> something like this:
>
> [f, x] = ksdensity(values)
>
> I used scipy's gaussian_kde to achieve the same result; however, I
> modified the matlab's code to f = ksdensity(values, x) and where x are
> fixed values. When x are fixed gaussian_kde works fine, but this is
> not what I need. I want to select x based on the input values as in
> [f, x] = ksdensity(values) which returns x based on the input. Is
> there a way to do this in scipy? For instance, if I have input values
> [0, 1, 40, 2, 3, 2] how do I get the range of x values?

isn't this just x = np.linspace(values.min(), values.max(), 100)  ?

from only a quick look at the matlab help:
"The density is evaluated at 100 equally spaced points that cover the
range of the data in x"

Josef

>
> Thank you very much.
>
> Tadas
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list