Skip to content
Snippets Groups Projects
ex2_3_2.py 434 B
Newer Older
  • Learn to ignore specific revisions
  • bjje's avatar
    bjje committed
    # Exercise 4.2.2
    
    import numpy as np
    
    Stas Syrota's avatar
    Stas Syrota committed
    
    
    bjje's avatar
    bjje committed
    # requires data from exercise 4.2.1
    
    Stas Syrota's avatar
    Stas Syrota committed
    from matplotlib.pyplot import figure, hist, show, subplot, xlabel, ylim
    
    bjje's avatar
    bjje committed
    
    
    Stas Syrota's avatar
    Stas Syrota committed
    figure(figsize=(8, 7))
    u = np.floor(np.sqrt(M))
    v = np.ceil(float(M) / u)
    
    bjje's avatar
    bjje committed
    for i in range(M):
    
    Stas Syrota's avatar
    Stas Syrota committed
        subplot(int(u), int(v), i + 1)
        hist(X[:, i], color=(0.2, 0.8 - i * 0.2, 0.4))
    
    bjje's avatar
    bjje committed
        xlabel(attributeNames[i])
    
    Stas Syrota's avatar
    Stas Syrota committed
        ylim(0, N / 2)
    
    
    bjje's avatar
    bjje committed
    show()
    
    
    Stas Syrota's avatar
    Stas Syrota committed
    print("Ran Exercise 4.2.2")