zoukankan      html  css  js  c++  java
  • Python for Data Science

    Chapter 5 - Basic Math and Statistics

    Segment 2 - Multiplying matrices and basic linear algebra

    import numpy as np
    from numpy.random import randn
    
    np.set_printoptions(precision=2)
    

    Multiplying matrices and basic linear algebra

    aa = np.array([[2.,4.,6.],[1.,3.,5.],[10.,20.,30.]])
    aa
    
    array([[ 2.,  4.,  6.],
           [ 1.,  3.,  5.],
           [10., 20., 30.]])
    
    bb = np.array([[0.,1.,2.],[3.,4.,5.],[6.,7.,8.]])
    bb
    
    array([[0., 1., 2.],
           [3., 4., 5.],
           [6., 7., 8.]])
    
    aa * bb
    
    array([[  0.,   4.,  12.],
           [  3.,  12.,  25.],
           [ 60., 140., 240.]])
    
    np.dot(aa,bb)
    
    array([[ 48.,  60.,  72.],
           [ 39.,  48.,  57.],
           [240., 300., 360.]])
  • 相关阅读:
    1001.A+B Format(20)
    大一下学期的自我目标
    re模块3
    re模块2
    re模块
    configParser模块
    logging模块
    hashlib模块
    sys模块
    isinstance函数
  • 原文地址:https://www.cnblogs.com/keepmoving1113/p/14258998.html
Copyright © 2011-2022 走看看