[Date Index]
[Thread Index]
[Author Index]
Re: can't translate 3D model to 0,0,0
*To*: mathgroup at smc.vnet.net
*Subject*: [mg88437] Re: can't translate 3D model to 0,0,0
*From*: "Szabolcs HorvÃt" <szhorvat at gmail.com>
*Date*: Mon, 5 May 2008 06:14:38 -0400 (EDT)
*References*: <fvhe4g$3v9$1@smc.vnet.net> <481C4C0F.9080900@gmail.com>
On Sat, May 3, 2008 at 2:20 PM, william parr <willpowers69 at hotmail.com> wrote:
>
> Hi Szabolcs,
>
> sorry, I don't understand. for which mean do you get 0,0,0? your final
> output is:
>
> Out[3]= {-1.55431*10^-17, -6.66134*10^-18, 4.44089*10^-18}
>
> I know it is very close to 0,0,0, but why is it not exactly 0,0,0?
We're working with inexact numbers (more precisely: machine precision
numbers, which have a precision of approx. 16 digits). It is expected
that the result cannot be _exactly_ zero because of numerical errors.
Since the numbers in the data are of order of magnitude of 1, and
we're working with ~ 16 digits of precision, the numerical error
simply cannot be much less than 10^-16.
In fact, Mathematica does a much better job with this than programming
languages that were not specifically designed for doing math. It uses
a special summation algorithm to minimize the numerical error (see the
Method option of Total)
For example, let's try a similar computation in both Mathematica and Python:
The Python version:
In [1]: from random import random
In [2]: data = [random() for x in xrange(1000000)]
In [3]: m = sum(data)/len(data)
In [4]: mdata = [x - m for x in data]
In [5]: sum(mdata)/len(mdata)
Out[5]: -1.2785664860182067e-014
The Mathematica version:
In[1]:= data = RandomReal[1, 1000000];
In[2]:= Mean[data - Mean[data]]
Out[2]= 2.01783*10^-17
Note that the error is 3 orders of magnitude smaller in the case of Mathematica.
> also,
> i've found with different models the means are slightly different (not
> surprisingly):
Of course: RandomReal generates a different sequence of points with
each invocation, so the numerical error will be different, too.
>
> In[6]:= b = RandomReal[1, {100, 3}];
> mb = Mean[b];
> Mean[# - mb & /@ b]
>
> Out[8]= {1.77636*10^-17, 8.88178*10^-18, 3.9968*10^-17}
>
>
> In[9]:= a = RandomReal[1, {100, 3}];
> ma = Mean[a];
> Mean[# - ma & /@ a]
>
> Out[11]= {2.05391*10^-17, 2.77556*10^-18, -6.66134*10^-18}
>
> am i missing the point somehow?
>
> the models I am working on are of the form in your demonstration, ie:
>
> {{0.96169, 0.0737274, 0.528905}, {0.297682, 0.741866, 0.67568},...,
> {0.584149, 0.95142, 0.0996909}}
>
Prev by Date:
**Re: Wolfram Workbench user experiences**
Next by Date:
**Interpolation with FourierTrigSeries with mathematica 6 tia sal2**
Previous by thread:
**Re: can't translate 3D model to 0,0,0**
Next by thread:
**StringMatchQ and Regular Expressions**
| |