def plot_errorbar1():
    with figsize(y=2):
        plt.figure()
        plot_errorbars([(160, 8, 'A'), (170, 8, 'B')],
                       xlims=(145, 185), ylims=(-1, 1))
        plt.show()
        plt.savefig('../figs/gh_errorbar1.png', pad_inches=0.)
Example #2
0
def plot_hypothesis5():
    weights = [
        158.0, 164.2, 160.3, 159.9, 162.1, 164.6, 169.6, 167.4, 166.4, 171.0,
        171.2, 172.6
    ]

    xs = range(1, len(weights) + 1)
    line = np.poly1d(np.polyfit(xs, weights, 1))

    with figsize(y=2.5):
        plt.figure()
        plt.errorbar(range(1, 13),
                     weights,
                     label='weights',
                     yerr=5,
                     fmt='o',
                     capthick=2,
                     capsize=10)
        plt.plot(xs, line(xs), c='r', label='hypothesis')
        plt.xlim(0, 13)
        plt.ylim(145, 185)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        show_legend()
    plt.savefig('../figs/gh_hypothesis5.png', pad_inches=0.1)
def plot_estimate_chart_3():
    with figsize(y=2.5):
        plt.figure()
        ax = plt.axes()
        ax.annotate('', xy=[1,159], xytext=[0,158],
                    arrowprops=dict(arrowstyle='->',
                                    ec='r', lw=3, shrinkA=6, shrinkB=5))

        ax.annotate('', xy=[1,159], xytext=[1,164.2],
                    arrowprops=dict(arrowstyle='-',
                                    ec='k', lw=3, shrinkA=8, shrinkB=8))

        est_y = (158 + .4*(164.2-158))
        plt.scatter ([0,1], [158.0,est_y], c='k',s=128)
        plt.scatter ([1], [164.2], c='b',s=128)
        plt.scatter ([1], [159], c='r', s=128)
        plt.text (1.0, 158.8, "prediction ($x_t)$", ha='center',va='top',fontsize=18,color='red')
        plt.text (1.0, 164.4, "measurement ($z$)",ha='center',va='bottom',fontsize=18,color='blue')
        plt.text (0, 157.8, "estimate ($\hat{x}_{t-1}$)", ha='center', va='top',fontsize=18)
        plt.text (0.95, est_y, "new estimate ($\hat{x}_{t}$)", ha='right', va='center',fontsize=18)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        ax.xaxis.grid(True, which="major", linestyle='dotted')
        ax.yaxis.grid(True, which="major", linestyle='dotted')
    plt.savefig('../figs/gh_estimate3.png', pad_inches=0.1)
Example #4
0
def plot_errorbar1():
    with figsize(y=2):
        plt.figure()
        plot_errorbars([(160, 8, 'A'), (170, 8, 'B')],
                       xlims=(145, 185),
                       ylims=(-1, 1))
        plt.show()
Example #5
0
def plot_hypothesis2():
    with figsize(y=2.5):
        plt.figure()
        plt.errorbar(range(1, 11), [169, 170, 169,171, 170, 171, 169, 170, 169, 170],
                     xerr=0, yerr=6, fmt='bo', capthick=2, capsize=10)
        plt.plot([1, 10], [169, 170.5], color='g', ls='--')
        plt.xlim(0, 11); plt.ylim(150, 185)
        plt.xlabel('day')
        plt.ylabel('lbs')
def plot_hypothesis2():
    with figsize(y=2.5):
        plt.figure()
        plt.errorbar(range(1, 11), [169, 170, 169,171, 170, 171, 169, 170, 169, 170],
                     xerr=0, yerr=6, fmt='bo', capthick=2, capsize=10)
        plt.plot([1, 10], [169, 170.5], color='g', ls='--')
        plt.xlim(0, 11); plt.ylim(150, 185)
        plt.xlabel('day')
        plt.ylabel('lbs')
    plt.savefig('../figs/gh_hypothesis2.png', pad_inches=0.1)
Example #7
0
def plot_estimate_chart_1():
    with figsize(y=2.5):
        plt.figure()
        ax = plt.axes()
        ax.annotate('', xy=[1,159], xytext=[0,158],
                    arrowprops=dict(arrowstyle='->', ec='r',shrinkA=6, lw=3,shrinkB=5))
        plt.scatter ([0], [158], c='b')
        plt.scatter ([1], [159], c='r')
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        ax.xaxis.grid(True, which="major", linestyle='dotted')
        ax.yaxis.grid(True, which="major", linestyle='dotted')
        plt.tight_layout()
Example #8
0
def plot_hypothesis3():
    weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6,
           169.6, 167.4, 166.4, 171.0, 171.2, 172.6]

    with figsize(y=2.5):
        plt.figure()

        plt.errorbar(range(1, 13), weights,
                     xerr=0, yerr=6, fmt='o', capthick=2, capsize=10)

        plt.xlim(0, 13); plt.ylim(145, 185)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
Example #9
0
def plot_hypothesis4():
    weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6,
           169.6, 167.4, 166.4, 171.0, 171.2, 172.6]

    with figsize(y=2.5):
        plt.figure()
        ave = np.sum(weights) / len(weights)
        plt.errorbar(range(1,13), weights, label='weights',
                     yerr=6, fmt='o', capthick=2, capsize=10)
        plt.plot([1, 12], [ave,ave], c='r', label='hypothesis')
        plt.xlim(0, 13); plt.ylim(145, 185)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        show_legend()
Example #10
0
def plot_hypothesis1():
    with figsize(y=2.5):
        plt.figure()
        plt.errorbar([1, 2, 3], [170, 161, 169],
                     xerr=0, yerr=10, fmt='bo', capthick=2, capsize=10)

        plt.plot([1, 3], [180, 160], color='g', ls='--')
        plt.plot([1, 3], [170, 170], color='g', ls='--')
        plt.plot([1, 3], [160, 175], color='g', ls='--')
        plt.plot([1, 2, 3], [180, 152, 179], color='g', ls='--')
        plt.xlim(0,4); plt.ylim(150, 185)
        plt.xlabel('day')
        plt.ylabel('lbs')
        plt.tight_layout()
def plot_hypothesis3():
    weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6,
           169.6, 167.4, 166.4, 171.0, 171.2, 172.6]

    with figsize(y=2.5):
        plt.figure()

        plt.errorbar(range(1, 13), weights,
                     xerr=0, yerr=6, fmt='o', capthick=2, capsize=10)

        plt.xlim(0, 13); plt.ylim(145, 185)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
    plt.savefig('../figs/gh_hypothesis3.png', pad_inches=0.1)
def plot_estimate_chart_1():
    with figsize(y=2.5):
        plt.figure()
        ax = plt.axes()
        ax.annotate('', xy=[1,159], xytext=[0,158],
                    arrowprops=dict(arrowstyle='->', ec='r',shrinkA=6, lw=3,shrinkB=5))
        plt.scatter ([0], [158], c='b')
        plt.scatter ([1], [159], c='r')
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        ax.xaxis.grid(True, which="major", linestyle='dotted')
        ax.yaxis.grid(True, which="major", linestyle='dotted')
        plt.tight_layout()
    plt.savefig('../figs/gh_estimate1.png', pad_inches=0.1)
def plot_hypothesis4():
    weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6,
           169.6, 167.4, 166.4, 171.0, 171.2, 172.6]

    with figsize(y=2.5):
        plt.figure()
        ave = np.sum(weights) / len(weights)
        plt.errorbar(range(1,13), weights, label='weights',
                     yerr=6, fmt='o', capthick=2, capsize=10)
        plt.plot([1, 12], [ave,ave], c='r', label='hypothesis')
        plt.xlim(0, 13); plt.ylim(145, 185)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        show_legend()
    plt.savefig('../figs/gh_hypothesis4.png', pad_inches=0.1)
def plot_hypothesis1():
    with figsize(y=2.5):
        plt.figure()
        plt.errorbar([1, 2, 3], [170, 161, 169],
                     xerr=0, yerr=10, fmt='bo', capthick=2, capsize=10)

        plt.plot([1, 3], [180, 160], color='g', ls='--')
        plt.plot([1, 3], [170, 170], color='g', ls='--')
        plt.plot([1, 3], [160, 175], color='g', ls='--')
        plt.plot([1, 2, 3], [180, 152, 179], color='g', ls='--')
        plt.xlim(0,4); plt.ylim(150, 185)
        plt.xlabel('day')
        plt.ylabel('lbs')
        plt.tight_layout()
    plt.savefig('../figs/gh_hypothesis1.png', pad_inches=0.1)
Example #15
0
def plot_hypothesis5():
    weights = [158.0, 164.2, 160.3, 159.9, 162.1, 164.6,
           169.6, 167.4, 166.4, 171.0, 171.2, 172.6]

    xs = range(1, len(weights)+1)
    line = np.poly1d(np.polyfit(xs, weights, 1))

    with figsize(y=2.5):
        plt.figure()
        plt.errorbar(range(1, 13), weights, label='weights',
                     yerr=5, fmt='o', capthick=2, capsize=10)
        plt.plot (xs, line(xs), c='r', label='hypothesis')
        plt.xlim(0, 13); plt.ylim(145, 185)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        show_legend()
Example #16
0
def plot_estimate_chart_2():
    with figsize(y=2.5):
        plt.figure()
        ax = plt.axes()
        ax.annotate('', xy=[1,159], xytext=[0,158],
                    arrowprops=dict(arrowstyle='->',
                                    ec='r', lw=3, shrinkA=6, shrinkB=5))
        plt.scatter ([0], [158.0], c='k',s=128)
        plt.scatter ([1], [164.2], c='b',s=128)
        plt.scatter ([1], [159], c='r', s=128)
        plt.text (1.0, 158.8, "prediction ($x_t)$", ha='center',va='top',fontsize=18,color='red')
        plt.text (1.0, 164.4, "measurement ($z$)",ha='center',va='bottom',fontsize=18,color='blue')
        plt.text (0, 157.8, "estimate ($\hat{x}_{t-1}$)", ha='center', va='top',fontsize=18)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        ax.xaxis.grid(True, which="major", linestyle='dotted')
        ax.yaxis.grid(True, which="major", linestyle='dotted')
Example #17
0
def plot_estimate_chart_2():
    with figsize(y=2.5):
        plt.figure()
        ax = plt.axes()
        ax.annotate('',
                    xy=[1, 159],
                    xytext=[0, 158],
                    arrowprops=dict(arrowstyle='->',
                                    ec='r',
                                    lw=3,
                                    shrinkA=6,
                                    shrinkB=5))
        plt.scatter([0], [158.0], c='k', s=128)
        plt.scatter([1], [164.2], c='b', s=128)
        plt.scatter([1], [159], c='r', s=128)
        plt.text(1.0,
                 158.8,
                 "prediction ($x_t)$",
                 ha='center',
                 va='top',
                 fontsize=18,
                 color='red')
        plt.text(1.0,
                 164.4,
                 "measurement ($z$)",
                 ha='center',
                 va='bottom',
                 fontsize=18,
                 color='blue')
        plt.text(0,
                 157.8,
                 "estimate ($\hat{x}_{t-1}$)",
                 ha='center',
                 va='top',
                 fontsize=18)
        plt.xlabel('day')
        plt.ylabel('weight (lbs)')
        ax.xaxis.grid(True, which="major", linestyle='dotted')
        ax.yaxis.grid(True, which="major", linestyle='dotted')
def plot_errorbar3():
    with book_format.figsize(y=1.5):
        book_plots.plot_errorbars([(160, 1, 'A'), (170, 9, 'B')], 
                                  xlims=(145, 185), ylims=(-1, 2))
def plot_errorbar3():
    with book_format.figsize(y=1.5):
        book_plots.plot_errorbars([(160, 1, 'A'), (170, 9, 'B')],
                                  xlims=(145, 185),
                                  ylims=(-1, 2))
def plot_errorbar1():
    with book_format.figsize(y=1.5):
        book_plots.plot_errorbars([(160, 8, 'A'), (170, 8, 'B')],
                                  xlims=(145, 185))
def plot_errorbar1():
    with book_format.figsize(y=1.5):
        book_plots.plot_errorbars([(160, 8, 'A'), (170, 8, 'B')],
                                   xlims=(145, 185))
Example #22
0
def plot_errorbar2():
    with figsize(y=2):
        plt.figure()
        plot_errorbars([(160, 3, 'A'), (170, 9, 'B')],
                       xlims=(145, 185), ylims=(-1, 1))
Example #23
0
#!/usr/bin/env python
# coding: utf-8

# mus and sigmas - не достаточно

# fixme: похоже чтобы воспользоваться корреляцией
#   нужно знать ковариационную матрицу

import numpy as np

from code.gaussian_internal import  plot_correlated_data
import code.mkf_internal as mkf_internal

height = [60, 62, 63, 65, 65.1, 68, 69, 70, 72, 74]
weight = [95, 120, 127, 119, 151, 143, 173, 171, 180, 210]
plot_correlated_data(height, weight, 'Height (in)', 'Weight (lbs)', False)

X = np.linspace( 1, 10, 100 )
Y = np.linspace( 1, 10, 100 )
print np.cov( X, Y )

mean = (2, 17)
cov = [[10.,0],
       [0,4.]]
       
# join prob.    
#mk.plot_3d_covariance( mean, cov )    

from book_format import set_figsize, figsize
with figsize(y=4):
    mkf_internal.plot_3_covariances()