import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
from scipy.stats import gaussian_kde
%matplotlib inline
tinker_df = pd.read_csv('VoltageData.csv')
print(tinker_df.head(30))
PWM V1 V2
0 0 83 83
1 5 41 41
2 10 66 66
3 15 98 98
4 20 131 131
5 25 164 164
6 30 197 197
7 35 230 230
8 40 264 263
9 45 297 297
10 50 330 330
11 55 363 363
12 60 396 396
13 65 430 429
14 70 464 463
15 75 496 496
16 80 529 529
17 85 563 563
18 90 596 596
19 95 629 629
20 100 662 662
21 105 695 695
22 110 729 728
23 115 761 761
24 120 795 794
25 125 826 824
26 130 854 851
27 135 877 870
28 140 895 883
29 145 911 892
PWM = tinker_df.PWM
V1 = tinker_df.V1
m, b = np.polyfit(PWM,V1,1)
Vth = m*PWM +b
plt.title("Voltage vs. Time")
plt.xlabel("Time")
plt.ylabel("Voltage" )
plt.plot(PWM, V1, 'b.', label='Data')
plt.legend()
plt.grid()
m, b = np.polyfit(PWM, V1, 1)
m, b
np.polyfit?
mu = 25
std = 6
N=25000
xs = np.random.normal(loc=mu, scale=std, size=N)
res=plt.hist(xs,bins=20)
xs = np.array(sorted(xs))
zs = np.array(sorted(np.random.normal(loc=0, scale=1.0, size=N)))
plt.plot(zs,xs,'b.')
plt.plot(zs, zs*std + mu,'r-')
print("x > 35 =", len(xs[xs>35])/N)
x > 35 = 0.04836
mu = 125
std = 9
N=52
xs = np.random.normal(loc=mu, scale=std, size=N)
res=plt.hist(xs,bins=20)