help-octave
[Top][All Lists]
Advanced

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

Re: Need to simplified a splitting and comparison commands


From: Juan Pablo Carbajal
Subject: Re: Need to simplified a splitting and comparison commands
Date: Wed, 12 Oct 2011 22:57:26 +0200

On Wed, Oct 12, 2011 at 7:20 PM, Faizal <address@hidden> wrote:
> First of all thank you for your response and apology for not mention about my
> objective.
> Basically, I would like to find a common number when I generate 100 or 200
> random number (0 to 9). With these numbers I split it to frame (in my
> example of 5 numbers). Therefore if 100 random numbers, I should be able to
> have 20 frames (in my example I denotes it as D1, D2, ....., D20).  With
> these frames (D1, D2,....,D20), I would like to make a a comparison between
> frames (it something like tree, means have few layers until it reach to the
> top comparison) to be able to find common number and it will go on until to
> the last layer or last two frame comparison. Each layer comparison I denotes
> as E1, E2..., E10 for 1st layer than F1, F2,...,F5 and so on until last
> layer.
>
> In my previous post, is just example of 20 random numbers.  If it is 100 or
> 200 numbers, for me to split the number is by inserting the D1 until D2 as
> shown (if R is the 100 random numbers)
> D1=R(1:1,1:5), D2=R(1:1,6:10), ......................., D20=R(1:1,96:100),
> and if I want to make a 1st layer comparison I need to repeat the intersect
> command
> E1=intersect(D1,D2), E2=intersect(D3,D4), ........, E10=intersect(D19,D20),
> than for 2nd layer comparison will be
> F1=intersect(E1,E2), ......, F5=intersect(E9,E10),
> and so on...
>
> If there is a shortest way to achieve this I really appreciated.  If not I
> need to repeat the command. If I have 200 or 300 random number, it will be
> long repeated command.
>
> I hope I explained clearly what I want to achieve
>
> Thank you again.
>
>
>
>
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/Need-to-simplified-a-splitting-and-comparison-commands-tp3896923p3898828.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>

I am not sure that I understand and my answer may not be adequate.

If you have a list N of 100 random integers in some interval L (do you
have a definite interval? like 0 to 100)
x = min(L):max(L)
c = hist(N,x)

Will give you a count of each number you have. Depending on the
relation between the size of your interval and the size of the list,
you may have many repeated elements and not only one.

If on the other side you are given n lists of k random integers N1,
N2, ..., Nn. And you want to find the elements that are common to all
the lists, then is required that the intersection between any two
lists is not empty. Then you can take N1, intersect with N2. If the
result is not empty you can compare it to N3... and so on. At the end
(or when you stopped because the next intersection was empty) you will
end up with the common elements. I do not know if this is optimal but
is easy to program.

I hope that was helpful.

-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

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