Exemple #1
0
def expon_cdf_pdf():
    x = np.linspace(0, 5, 100)##return evenly spaced samples, calculated over the interval [0,5]
    rv=E(scale = 1)#the scale is 1
    
    plt.plot(x, rv.pdf(x), color='blue')#make pdf chart 
    plt.plot(x, rv.cdf(x), color='red') #make cdf chart
    plt.savefig('fig.png')
Exemple #2
0
def law_of_large_numbers():
    x = np.arange(1, 1001, 1) 
    r = bernoulli.rvs(0.3, size=1000)
    y = []
    rsum =0.0
    for i in range(1000):
        if r[i]==1:
            rsum=rsum+1
        y.append(rsum/(i+1))
    plt.plot(x, y, color='red')
    plt.savefig('law_of_large_numbers.png')
Exemple #3
0
def law_of_large_numbers():
    x = np.arange(1, 1001, 1) 
    r1 = binom.rvs(10, 0.6, size=1000)
    r2 = poisson.rvs(mu=6, size=1000)
    r3 = norm.rvs(loc=6, size=1000)

    y = []
    rsum=0.0
    for i in range(1000):
        rsum=rsum+(r1[i]+r2[i]+r3[i])
        y.append(rsum/((i+1)*3)-6)

    plt.plot(x, y, color='red')
    plt.savefig('law_of_large_numbers.png')
Exemple #4
0
def linregress1():
    x = np.linspace(-5, 5, num=150)
    y = x + np.random.normal(size=x.size)
    y[12:14] += 10 
    
    slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
    log(slope)
    log(intercept)
    log(r_value)
    log(p_value)
    log(std_err)
    
    plt.plot(x, y, 'b.')
    plt.plot(x, slope * x + intercept, 'r-')
    plt.savefig('linregress1.png')
Exemple #5
0
def norm_pdf():
    x = np.linspace(-10, 10, 100)#return evenly spaced samples, calculated over the interval [-10,10]
    rv1=N(loc=0, scale = 1)#the mean is 0, the standard deviation is 1
    rv2=N(loc=-5, scale = 1)#the mean is -5, the standard deviation is 1
    rv3=N(loc=0, scale = 3)#the mean is 0, the standard deviation is 3

    plt.plot(x, rv1.pdf(x), color='green')#make chart
    plt.plot(x, rv2.pdf(x), color='blue')#make chart
    plt.plot(x, rv3.pdf(x), color='red')#make chart
    plt.savefig('fig.png')
Exemple #6
0
def expon_pdf():
    x = np.linspace(0, 20, 100)#return evenly spaced samples, calculated over the interval [0,20]
    rv1=E(scale = 1.5)#the scale is 1.5
    rv2=E(scale = 1.0)#the scale is 1.0
    rv3=E(scale = 0.5)#the scale is 0.5

    plt.plot(x, rv1.pdf(x), color='green')#make chart
    plt.plot(x, rv2.pdf(x), color='blue')#make chart
    plt.plot(x, rv3.pdf(x), color='red')#make chart
    plt.savefig('fig.png')