help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] constructing a discrete dataset


From: Jean Dubois
Subject: Re: [newbie] constructing a discrete dataset
Date: Wed, 29 Jan 2014 21:09:06 +0100

2014-01-29 c. <address@hidden>:
>
> Please use "reply all" instead of "reply" to keep the list in CC.
sorry, I always have to remember the default reply option isn't the right one
>
> On 29 Jan 2014, at 19:38, Jean Dubois <address@hidden> wrote:
>
>> 2014-01-29 c. <address@hidden>:
>>>> On 29 Jan 2014, at 17:07, Jean Dubois <address@hidden> wrote:
>>>>
>>>>> I'd like to generate every possible combination a b c d e f for three
>>>>> possible values (1, 2, 3) of each variable
>>>>> Something which starts like this:
>>>>> 1 1 1 1 1 1
>>>
>>> On 29 Jan 2014, at 17:25, c. <address@hidden> wrote:
>>>
>>>> If I understand correctly what you want to do is count fro 0 to 3^7-1 in 
>>>> base 3:
>>> oops, you actually wanted 6 digits, not 7, so that's 3^6-1, not 3^7-1:
>>>
>>> ii = [0:3^6-1].';
>>> for jj = 1:6
>>>  digit(:, jj) = fix (ii / 3^(6-jj));
>>>  ii -= digit(:, jj) * 3^(6-jj);
>>> endfor
>>> digit += 1;
>>>
>
>> Thanks a lot, this does indeed what I asked. I have to admit I don't
>> yet understand your code. Could you just  you explain what the code -=
>> does? (help -= doesn't give me an answer)
>
> you are right, there is no 'help' for '-=' but there is an enty in the 
> manual, try
>
> doc -=
I didn't know that, thanks
> anyway,
>
> a -= b
>
> is nothing else but a shortcut for
>
> a = a - b
Well I learned something
>> I also tried to make it work for other bases and number of digits like this:
>> base=input('base? ')
>> nod=input('number of digits? ')
>> ii = [0:base^nod-1].';
>> for jj = 1:nod
>>  digit(:, jj) = fix (ii / base^(nod-jj));
>>  ii -= digit(:, jj) * base^(nod-jj);
>> endfor
>> digit += 1;
>>
>> It breaks however for some values e.g. base 11 and 12 digits
>
>
> that's not surprising as in that case you are asking to create a matrix with
>
> 11^12 = 3.1384e+12
>
> entries, which is more that Octave can index
> unless you compiled with 64bit indexing enabled:
>
>>> intmax
> ans = 2147483647
>
> do you really need to create a table that large?

It's a kind of brute force method to solve a combinatoric problem
(which I know can be solved simpler),but  I just wanted to know if it
could be solved brute force like and how long it would take.
I have installed octave on a 64 bit linux-system but that doesn't seem
to be sufficient to have the 64bit indexing enabled?
Could you supply a reference to the procedure to compile octave with
64bit indexing enabled

kind regards,
jean


reply via email to

[Prev in Thread] Current Thread [Next in Thread]