[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: finding approximate 'least common factor'
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: finding approximate 'least common factor' |
Date: |
Thu, 26 May 2011 16:26:52 -0500 |
On 24 May 2011 10:41, Przemek Klosowski <address@hidden> wrote:
> I have numbers which are approximately (but not exactly) an integer number
> of some basic quantity. How would you estimate that basic quantum? For
> instance, if the data is:
>
> a= [5500 3800 3300 3800 4000 5500 2600 3800 5500 2500 4000 6000 4000 450
> 1550 1000 3800 5300 5300 1800 3800 1550 2500 3300 1300 2500 3300 2500 1550
> 5500 2200 3500 3300 2200 1300 800 2200 1000 2500 5300 3000 2200 2200 2200
> 4000 2400 2200 5500 4000 800 2200 2600 450 450 ]
[snip]
> Can anyone think of a more precise numerical algorithm?
The subject of this thread should be about greatest, not least common
factor, right?
So it's a problem about finding the relative mininum of the following
objective functions:
f = @(x) norm(fmod(bsxfun(@rdivide, a(:), x(:)'),1),"columns");
i.e. looking at the x that minimises the norm of the fractional part
of the vector a divided by a proposed quantum x.
I tried this, but that object function is incredibly noisy, naturally,
for arbitrary x. It is, however, rather clean for integer x of a
proposed quantum.
Of course, for your proposed data ordinary gcd works:
gcd(num2cell(a){:})
HTH,
- Jordi G. H.