[SciPy-User] sample from kernel density estimate
josef.pktd at gmail.com
josef.pktd at gmail.com
Tue Feb 2 11:08:03 EST 2010
On Tue, Feb 2, 2010 at 10:57 AM, Alan G Isaac <aisaac at american.edu> wrote:
>> On Tue, Feb 2, 2010 at 10:23 AM, Alan G Isaac<aisaac at american.edu> wrote:
>>> I have a kernel density estimate from scipy.stats.gaussian_kde.
>>> What's the best way to sample from it? (Not from the underlying data.)
>
>
> On 2/2/2010 10:31 AM, josef.pktd at gmail.com wrote:
>> I think stats.kde.gaussian_kde.resample does it.
>> If I remember correctly, it samples from the underlying data and adds
>> a normal noise. I think I read somewhere that that is equivalent to
>> sampling from the kernel density directly.
>
>
> That appears to be correct.
> I was using the online docs,
> which did not show this method.
I added it to the list of methods in the docs.
Josef
> However, `help` does show it::
>
> | resample(self, size=None)
> | Randomly sample a dataset from the estimated pdf.
> |
> | Parameters
> | ----------
> | size : int, optional
> | The number of samples to draw.
> | If not provided, then the size is the same as the underlying
> | dataset.
> |
> | Returns
> | -------
> | dataset : (self.d, size)-array
> | sampled dataset
>
> Thanks,
> Alan
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
More information about the SciPy-User
mailing list