<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Fit X in the gmm model for 1, 2, ... 10 components.  Hint
Step1:  Calculate the AIC and BIC for each of these 10 models, and find the best model.
Step2:  Plot the AIC and BIC
Step3:  Define your PDF by evenly distributing 1000 points in some range.  Look up what the eval method of the model instance does, and evaluate on your 1000 data points x.  You should be able to extract a pdf, and the individual responsibilities for each of the components.
Step4:  Plot x as a histogram, and the PDF values over your x_i values.
<ASSISTANT_TASK:>
Python Code:
gmms = [GMM(i).fit(X) for i in range(1,10)]
Explanation: Fit X in the gmm model for 1, 2, ... 10 components.  Hint: You should create 10 instances of a GMM model, e.g. GMM(?).fit(X) would be one instance of a GMM model with ? components.
End of explanation
aics = [g.aic(X) for g in gmms]
bics = [g.bic(X) for g in gmms]
Explanation: Calculate the AIC and BIC for each of these 10 models, and find the best model.
End of explanation
plt.plot(aics)
plt.plot(bics)
Explanation: Plot the AIC and BIC
End of explanation
# Data x_i
x = np.linspace(-6,6,1000)
pdf = gmms[2].score_samples(x.reshape(-1,1))
Explanation: Define your PDF by evenly distributing 1000 points in some range.  Look up what the eval method of the model instance does, and evaluate on your 1000 data points x.  You should be able to extract a pdf, and the individual responsibilities for each of the components.
End of explanation
plt.plot(np.linspace(-6,6,1000),np.exp(pdf[0]))
plt.hist(X,bins='auto',normed=True)
Explanation: Plot x as a histogram, and the PDF values over your x_i values.
End of explanation
<END_TASK>