0
votes

I have a data set which has values in the range of 1e-2 and 1e-3. I have the following code to obtain the values and plot the distribution.

def get_pdf(data):
    a = np.array(data)
    ex = st.gaussian_kde(a)
    x = np.linspace(0, max(data), max(data))
    y = ag(ex)
    return x, y

data_list = dataset.iloc[:, 2].tolist()
data = [i * 10000 for i in data_list]
x_pdf, y_pdf = get_pdf(data)

plt.figure()
plt.plot(x_pdf, y_pdf, label='PDF of values')
plt.legend()
plt.xlabel('Value')
plt.ylabel('Probability')
output_image = "ex.png"
plt.savefig(output_image)
plt.close()

However, this code does not work unless each value in the data set is multiplied by 10,000. I want to use the values in my data set as it is without multiplying. I would really appreciate some help. Thanks.

1

1 Answers

0
votes

You should try : x = np.linspace(min(data), max(data), len(data))