Mathematica中的精度精度 Accuracy 和precision辨析,

有些时候, accuracy和precision似乎是同义的术语,

accuracy是指测量值的精确程度。换句话说,是指测量值接近真实值的程度。

对于一系列测量值,precision指的是测量质量相同的若干点之间的靠近程度。

这个是工程数据处理要用到的,精度知识。

我还是没有理解,查看了mathemactica的手册:

Precision[x]
gives the effective number of digits of precision in the number x.

Accuracy[x]
gives the effective number of digits to the right of the decimal point in the number x.

In[1]:= Accuracy[123456789.987654321]

Out[1]= 9.

 

In[1]:= Precision[123456789.987654321]

Out[1]= 17.0915

因为mathematica默认的是MachinePrecision,一般是小数点后面的5位小数,

In[1]:= 2.12345678901

Out[1]= 2.12346

所以要自己设置精度,而设置精度的方法有几个函数:

SetAccuracy[expr,a]
yields a version of expr in which all numbers have been set to have accuracy a.

SetPrecision[expr,p]
yields a version of expr in which all numbers have been set to have precision p.

In[2]:= SetAccuracy[2.1234567890, 15]

Out[2]= 2.12345678900000

In[3]:= SetPrecision[2.1234567890, 15]

Out[3]= 2.12345678900000

另外还有犀利的N,不过关于N,

非常简单,

N[expr,n]
attempts to give a result with n-digit precision.

 可以根据你输入的来确定小数点位置,但是感觉没有上面两个好用,

当然,达到一定的数位后要发生溢出(可能术语不对)如:

In[4]:= SetAccuracy[2.1234567890, 25]

Out[4]= 2.1234567890000000112138423

后面的一些不知道是什么问题,待解决。

 


posted on 2012-03-25 14:04  dragonlive  阅读(3439)  评论(0)    收藏  举报

导航