Python Stats

Great journey’s start with a single step. Here is a simple linear regression plot using python. Let’s see where this takes us.

import numpy as np
from numpy.polynomial.polynomial import polyfit
from scipy import stats
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv(“tntot-stats.csv”)
x = np.array(df[‘Pre-Roll’].values)
y = np.array(df[‘Mid-Roll’].values)

slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)

print (slope, intercept, r_value, p_value)

# Fit with polyfit
b, m = polyfit(x, y, 1)

# print (“poly: “+str(m))

plt.plot(x, y, ‘.’)
plt.plot(x, b + m * x, ‘-‘)

plt.title(“Otto: Python Regression: Do TNTOT Pre-Rolls predict Midrolls?”)
plt.xlabel(‘Prerolls’)
plt.ylabel(‘Midrolls’)
plt.text(10000, 1200000,’Slope: ‘+str(round(slope,3)), ha=’left’, va=’center’)
plt.text(10000, 1100000,’Intercept: ‘+str(round(intercept,3)), ha=’left’, va=’center’)
plt.text(10000, 1000000,’R-squared: ‘+str(round(r_value,3)), ha=’left’, va=’center’)
plt.text(10000, 900000,’P-value: ‘+str(round(p_value,3)), ha=’left’, va=’center’)
plt.text(50000,400000, ‘Nov 2019 MTD’)
plt.text(50000,300000, ‘NBA.com TNTOT Desktop’)

plt.annotate(‘>95%’, xy=(30000, 1000000), xycoords=’data’,
xytext=(0.6, 0.75), textcoords=’axes fraction’,
arrowprops=dict(facecolor=’red’, shrink=0.05),
horizontalalignment=’right’, verticalalignment=’top’,
)


# plt.show() Need tkinter to have interactive
plt.savefig(“mpgraph.png”)

# plt.hist(x)
# plt.ylabel(‘No of times’)
# plt.savefig(“mpgraph2.png”)

Michael J. Pierce

C.S. Lewis

Lewis, grieving the death of his wife, Joy:

No one ever told me that grief felt so like fear. I am not afraid, but the sensation is like being afraid. The same fluttering in the stomach, the same restlessness, the yawning. I keep on swallowing.

At other times it feels like being mildly drunk, or concussed. There is a sort of invisible blanket between the world and me. I find it hard to take in what anyone says. Or perhaps, hard to want to take it in. It is so uninteresting. Yet I want the others to be about me. I dread the moments when the house is empty. If only they would talk to one another and not to me.

There are moments, most unexpectedly, when something inside me tries to assure me that I don’t really mind so much, not so very much, after all. Love is not the whole of a man’s life. I was happy before I ever met H. I’ve plenty of what are called ‘resources.’ People get over these things. Come, I shan’t do so badly. One is ashamed to listen to this voice but it seems for a little to be making out a good case. Then comes a sudden jab of red-hot memory and all this ‘commonsense’ vanishes like an ant in the mouth of a furnace.

From A Grief Observed
Compiled in A Year with C.S. Lewis