<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 KDE without dataset saved in object
Less storage & memory needed
Step1:  Notes
<ASSISTANT_TASK:>
Python Code:
from scipy import stats
import numpy as np
# making kde
values = np.arange(10)
kde = stats.gaussian_kde(values)
np.median(kde.resample(100000))
def KDE_make_means(kde, size=10):
    func = lambda x : np.random.randint(0, x.n, size=x.d)
    kde.means = [kde.dataset[:, func(kde)] for i in xrange(size)]
    kde.means_n = len(kde.means)
    #kde.dataset = None   
#KDE_make_means(kde)
def KDE_save_means(kde, size):
    indices = np.random.randint(0, kde.n, size=size)
    kde.means = kde.dataset[:, indices]
    kde.means_size = size
    
KDE_save_means(kde, size=10)
kde.dataset = None
def KDE_resample(kde):
    norm = np.transpose(np.random.multivariate_normal(np.zeros((kde.d,), float), kde.covariance, 
                                                      size=kde.means_size))
    print(kde.means)
    return kde.means + norm
KDE_resample(kde)
Explanation: KDE without dataset saved in object
Less storage & memory needed
End of explanation
%load_ext rpy2.ipython
%%R
library(dplyr)
library(tidyr)
library(ggplot2)
library(vegan)
%%R
data(varespec)
varespec %>% head
Explanation: Notes:
cannot get rid of dataset attribute in order to free up memory
End of explanation
<END_TASK>