python numpy machine epsilon

后端 未结 3 1138
鱼传尺愫
鱼传尺愫 2020-11-28 03:27

I am trying to understand what is machine epsilon. According to the Wikipedia, it can be calculated as follows:

def machineEpsilon(func=float):
    machine_e         


        
3条回答
  •  一向
    一向 (楼主)
    2020-11-28 04:11

    An easier way to get the machine epsilon for a given float type is to use np.finfo():

    print(np.finfo(float).eps)
    # 2.22044604925e-16
    
    print(np.finfo(np.float32).eps)
    # 1.19209e-07
    

提交回复
热议问题