<commit_before>import sys
import re
from StringIO import StringIO
import numpy as np
import matplotlib

matplotlib.use('pdf')
import matplotlib.pyplot as plt

chain = str(sys.argv[2])

with open(str(sys.argv[1])+'/ip_raw_chain_sub'+chain+'.m', 'r') as fin:
    header = fin.readline()

    # Sort out the dimension of the 2D array of samples
    dims = re.findall(r'\d+', header)
    dims = [int(dim) for dim in dims]
    dims[0] -= 1

    # Ignore first line because laziness
    # for i in range(20):
    samples = fin.readline()

    # Now read all and ignore last line
    samples = fin.readlines()
    samples = samples[0:-1]

    # Now join all up and use magic numpy read help
    samples = ' '.join(samples)
    samples = np.loadtxt(StringIO(samples))

num_samples = samples.shape[0]

mins = np.array([0.95, 0.9, 0.9, 0.9, 0.9])
maxs = np.array([1.05, 1.1, 1.1, 1.1, 1.1])

samples[:,3] = mins[3] + (samples[:,3] * (maxs[3] - mins[3]))
samples[:,4] = mins[4] + (samples[:,4] * (maxs[4] - mins[4]))

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.scatter(samples[5000:,3], samples[5000:,4])
ax.set_xlabel('k_xkwlx')
ax.set_ylabel('k_cd')
fig.savefig('joint.pdf')

ax.cla()

eta = 0.906 * samples[:,3] + 0.478 * samples[:,4]

ax.hist(eta[5000:], bins=20)
fig.savefig('eta.pdf')

print "eta mean:", np.mean(eta[5000:])
print "eta std:", np.std(eta[5000:])  # should be 0.00791<commit_msg>Make plotter use only end of the chain<commit_after>import sys
import re
from StringIO import StringIO
import numpy as np
import matplotlib

matplotlib.use('pdf')
import matplotlib.pyplot as plt

chain = str(sys.argv[2])

with open(str(sys.argv[1])+'/ip_raw_chain_sub'+chain+'.m', 'r') as fin:
    header = fin.readline()

    # Sort out the dimension of the 2D array of samples
    dims = re.findall(r'\d+', header)
    dims = [int(dim) for dim in dims]
    dims[0] -= 1

    # Ignore first line because laziness
    # for i in range(20):
    samples = fin.readline()

    # Now read all and ignore last line
    samples = fin.readlines()
    samples = samples[0:-1]

    # Now join all up and use magic numpy read help
    samples = ' '.join(samples)
    samples = np.loadtxt(StringIO(samples))

num_samples = samples.shape[0]
N = 60000

mins = np.array([0.95, 0.9, 0.9, 0.9, 0.9])
maxs = np.array([1.05, 1.1, 1.1, 1.1, 1.1])

samples[:,3] = mins[3] + (samples[:,3] * (maxs[3] - mins[3]))
samples[:,4] = mins[4] + (samples[:,4] * (maxs[4] - mins[4]))

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.scatter(samples[N:,3], samples[N:,4])
ax.set_xlabel('k_xkwlx')
ax.set_ylabel('k_cd')
fig.savefig('joint.pdf')

ax.cla()

eta = 0.906 * samples[:,3] + 0.478 * samples[:,4]

ax.hist(eta[N:], bins=20)
fig.savefig('eta.pdf')

print "eta mean:", np.mean(eta[N:])
print "eta std:", np.std(eta[N:], ddof=1)  # should be 0.00791
{'fraction_non_alphanumeric': 0.1844900849858357, 'fraction_numerical': 0.05524079320113314, 'mean_word_length': 3.755892255892256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '3848751', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1144, 'n_words': 289}