An example of "society" done using 1e6 members.

   n=: 1e6            NB. number of members
   f=: n ?@$ 151      NB. number of friends for each member (0 to 150)
   s=: (~:/"1 # ]) (I.f) ,. (+/f) ?@$ n

The last expression computes (member,friend) ordered pairs, eliminating
self-friends.  Now compute "anyone who considers me a friend is my friend":

   timer 's,|."1 s'
1.50728

   $s
74956470 2

The representation is key here.  Representing the relation as ordered pairs
makes it clear what's being computed, and to do it you just have to reverse
the ordered pairs, namely |."1 s .  It also makes it clear that this is the
symmetric closure (and I was wrong at the beginning when I said it was the
transitive closure).

Understanding the representation reveals another strong contender for
shortest program: s itself.  If you think of s not as ordered pairs but as *
unordered* pairs, then the symmetric closure is a no-op, or at least the
identity.  The representation may be adequate depending on what else you
want to compute.  This claim is harder to justify with the original
representation presented in this thread, (member,list of friends).

I failed to do an example with 1e7 members.  The expected number of friends
is 75 per the Dunbar requirement.  For n members, the size of s is
(75*n),2.  On J64, integers are 8 bytes each, so the total number of bytes
is 8**/(75*n),2 and for n=1e7 equates to 12 GB.




On Fri, Sep 13, 2013 at 10:55 AM, Richard Gaylord <rjgayl...@gmail.com>wrote:

> i'll do a Timing test with WL and get back to you on the results.
>
> since the evolutionary psychologist Robin Dunbar says that a person's
> social network is limited to about 150 other individuals
>
> http://en.wikipedia.org/wiki/Dunbar's_number
>
> i'll let society consist of 10,000,000 individuals
>
> that would correspond to the size of the population of Tokyo or Jakarta
>
> http://en.wikipedia.org/wiki/List_of_cities_proper_by_population
>
> with each individual having a random number of friends ranging from 0 (the
> loner) to 150. and then i'll make the 'reciprocal friendship' assumption so
> that every friend of an individual has that individual as his friend.
>
> so for society, i'll create a sorted (i'll sort by the first element which
> represents the individual's name) list of 10,000,000 elements where each
> element is an ordered pair whose first element is the name (represented by
> a number) of an individual and whose second element is a sorted list of
> names (represented by numbers) of random length ranging from 0 to 150. then
> i'll time how long it takes for WL to 'symmetrize' society into symSoc.
>
> this may take me a couple of days to get to since i'm dealing with ongoing
> health issues.
>
> stay tuned.
>
> btw - i'm glad we're doing this since Wolfram people did a comparision of
> program conciseness in various languages but left out J and APL for some
> reason.
>
>
> http://blog.revolutionanalytics.com/2012/11/which-programming-language-is-the-most-concise.html
>
>
> On Fri, Sep 13, 2013 at 11:57 AM, Roger Hui <rogerhui.can...@gmail.com
> >wrote:
>
> > Thanks for the compliment, but I am still interested in how the WL
> program
> > worked.
> >
> >
> > --
>
> *"Those who would sacrifice freedom for security deserve neither." -
> Benjamin Franklin*
>
>
> *"I think that the very notion that equations are a good approach to
> describing the natural world is a little bizarre."
>  - Stephen Wolfram*
>
> *
> *
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to