In [7]:
import numpy as np
import scipy as sp
import scipy.stats as stats
import pandas as pd
import matplotlib.pyplot as plt
import diptest.diptest
%matplotlib inline
In [8]:
from numpy.random import choice
In [3]:
dat = np.random.normal(size=200)
dat2 = np.random.normal(loc=4, size=200)
datC = np.concatenate([dat, dat2])
In [4]:
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 10))
ax1.hist(dat)
ax2.hist(datC)
Out[4]:
In [5]:
print(diptest.diptest.diptest(dat))
kde = sp.stats.gaussian_kde(dat)
x_grid = np.linspace(min(dat), max(dat), 1000)
plt.plot(np.cumsum(kde.evaluate(x_grid)))
In [6]:
print(diptest.diptest.diptest(datC))
kde = sp.stats.gaussian_kde(datC)
x_grid = np.linspace(min(datC), max(datC), 1000)
plt.plot(np.cumsum(kde.evaluate(x_grid)))
In [26]:
import tapeAnalyst.analysis as analysis
import tapeAnalyst.gel_processing as gp
In [27]:
dfS = pd.read_csv('/Users/fearjm/devel/tapeAnalyst/data/JH_sample.csv', encoding='ISO-8859-1')
dfS.columns = ['wellID', 'conc', 'description', 'alert', 'notes']
In [129]:
gel = gp.TapeStationGel('/Users/fearjm/devel/tapeAnalyst/data/JH_gel.png', dfS)
In [311]:
lane = gel.lanes[13]
sec = lane.laneMean[140:400]
smooth = sp.signal.convolve(sec, sp.signal.hamming(10))
x_grid = np.arange(0, smooth.shape[0])
norm = smooth / smooth.sum()
sim = np.random.choice(x_grid, size=3000, replace=True, p=norm)
print(analysis.diptest(sec))
fig, (ax1, ax2) = plt.subplots(2, 1)
ax1.plot(sec)
ax2.plot(smooth)
Out[311]:
In [ ]:
In [14]:
np.sort(norm)
In [ ]:
diptest.diptest.CV?
In [ ]:
diptest.diptest._dip(sec)
In [ ]:
sp.random.sample?
In [ ]:
plt.plot(sec)
In [ ]:
myCDF = np.cumsum(sec)
plt.plot(myCDF)
In [ ]:
invCDF = 1 / myCDF
plt.plot(invCDF)
In [ ]:
invCDF
In [ ]:
plt.plot(x_grid, sp.stats.norm.cdf(x_grid))
In [15]:
plt.plot(myCDF / myCDF.max())
In [16]:
plt.plot(sec)
Out[16]:
In [17]:
x_grid = np.linspace(0, 250, 10000)
In [18]:
x_grid = np.arange(0, len(sec))
In [24]:
xs = np.random.choice(x_grid, size=1000000, replace=True, p=sec / sec.sum())
In [25]:
kde = sp.stats.gaussian_kde(xs)
plt.plot(kde.evaluate(x_grid))
Out[25]:
In [ ]:
In [ ]: