<jupyter_start><jupyter_text>Estimate raw price<jupyter_code>raw
len(err)
plt.figure()
counts, bins = np.histogram(raw,bins=100)
plt.hist(bins[:-1], bins, weights=counts);
mu = np.mean(raw)
sig = np.std(raw)
xrg = np.arange(-0.15, 0.15, 0.001)
print(np.mean(raw), np.std(raw))
(mu, a, b) = est(raw)
print(mu, a, b)
cc=(bins[1]-bins[0])*len(raw)
plt.figure()
plt.hist(bins[:-1], bins, weights=counts/cc, label='Histogram');
plt.plot(xrg, stats.norm.pdf(xrg, mu, sig), '-.', label='Gaussian est.')
# plt.plot(xrg, y, 'r-', label='kern est. PDF')
plt.plot(xrg, ggd(xrg, b, mu, a), 'g-', label='GGD est. (p=%.3f)'%b)
plt.title('Estimation of raw log return')
plt.legend()
plt.savefig('./figs/est_rt.eps')
ggd2lik=0
for xi in err:
    tmp = stats.norm.pdf(xi, mu, sig)
    if tmp > 0:
        ggd2lik += log(tmp)
ggd2lik
ggdplik=0
for xi in err:
    tmp = ggd(xi, b, mu, a)
    if tmp > 0:
        ggdplik += log(tmp)
ggdplik<jupyter_output><empty_output><jupyter_text>Estimate error<jupyter_code>err
len(err)<jupyter_output><empty_output><jupyter_text>plt.figure(figsize=(20,10))plt.plot(err, np.zeros_like(err), '.')<jupyter_code>plt.figure()
counts, bins = np.histogram(err,bins=100)
plt.hist(bins[:-1], bins, weights=counts);
mu = np.mean(err)
sig = np.std(err)
xrg = np.arange(-0.15, 0.15, 0.001)<jupyter_output><empty_output><jupyter_text>plt.figure()counts, bins = np.histogram(err,bins=100)cc=(bins[1]-bins[0])*len(err)plt.hist(bins[:-1], bins, weights=counts/cc);plt.plot(xrg, stats.norm.pdf(xrg, mu, sig)) def fh(x, xs, h):    def kern(dx):        return np.exp(-dx**2/2)/np.sqrt(2*np.pi)    res = 0    for xi in xs:        res += kern((xi-x)/h)    res = res / (len(xs)*h)    return res y = [fh(x, err, 1.06*sig*len(err)**-0.2) for x in xrg] plt.figure(figsize=(20,10))plt.hist(bins[:-1], bins, weights=counts/cc, label='hist');plt.plot(xrg, stats.norm.pdf(xrg, mu, sig), label='norm')plt.plot(xrg, y, 'r-', label='kern est. PDF')plt.legend()<jupyter_code>print(np.mean(err), np.std(err))
(mu, a, b) = est(err)
print(mu, a, b)
cc=(bins[1]-bins[0])*len(err)
plt.figure()
plt.hist(bins[:-1], bins, weights=counts/cc, label='Histogram');
plt.plot(xrg, stats.norm.pdf(xrg, mu, sig), '-.', label='Gaussian est.')
# plt.plot(xrg, y, 'r-', label='kern est. PDF')
plt.plot(xrg, ggd(xrg, b, mu, a), 'g-', label='GGD est. (p=%.3f)'%b)
plt.title('Estimation of predictive error')
plt.legend()
plt.savefig('./figs/est_err.eps')
ggd2lik=0
for xi in err:
    tmp = stats.norm.pdf(xi, mu, sig)
    if tmp > 0:
        ggd2lik += log(tmp)
ggd2lik
ggdplik=0
for xi in err:
    tmp = ggd(xi, b, mu, a)
    if tmp > 0:
        ggdplik += log(tmp)
ggdplik<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22172284644194756, 'fraction_numerical': 0.027715355805243445, 'mean_word_length': 4.646934460887949, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '438107', 'license': 'MIT', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1198, 'n_words': 232, 'path': 'err_analysis.ipynb', 'repo_name': 'Aaanonymousss/G4P', 'size': '2670'}