Re: Re: newbie is looking foracustomDistributionfunction

*To*: mathgroup at smc.vnet.net*Subject*: [mg50437] Re: [mg50411] Re: [mg50383] newbie is looking foracustomDistributionfunction*From*: DrBob <drbob at bigfoot.com>*Date*: Fri, 3 Sep 2004 03:36:27 -0400 (EDT)*References*: <200409010549.BAA29848@smc.vnet.net> <003d01c49152$37f20450$3f57fea9@Tomas>*Reply-to*: drbob at bigfoot.com*Sender*: owner-wri-mathgroup at wolfram.com

No question, a different mapping into the reals gives a different distribution function. But if you've chosen a mapping, you know it both ways, so you know the order you speak of. Anyway, my solution doesn't depend on any of that. Since the OP wanted to sample from a list based on frequency in the list, this works: random[a:{__}]:=a[[Random[Integer,{1,Length@a} ]]] Bobby On Thu, 02 Sep 2004 20:06:18 -0500, Tomas Garza <tgarza01 at prodigy.net.mx> wrote: > Quite right. However, implicit in the mapping of a List into the real line > is the problem of order. If the mapping takes, say, the element {a, a} to 0, > {a, b} to 1, and {a, c} to 2, etc., what would be the meaning of the > probability that the result of the experiment takes a value less than or > equal to 2? (Yes, I realize that once you define a fixed order in twocombs, > such as that produced by Distribute, this would be interpreted as the > probability of {{a, a}, {a, b}, {a,c}}. But this goes well above my head). > > Tomas Garza > ----- Original Message ----- > From: "DrBob" <drbob at bigfoot.com> To: mathgroup at smc.vnet.net > To: "Tomas Garza" <tgarza01 at prodigy.net.mx>; <mathgroup at smc.vnet.net> > Sent: Thursday, September 02, 2004 12:20 PM > Subject: [mg50437] Re: [mg50411] Re: [mg50383] newbie is looking for > acustomDistributionfunction > > >> More generally, any mapping of a finite measure space into the extended > real line implies a measure on the Borel sets, giving rise to a distribution > function. It isn't difficult to map the values of a List into the reals--to > Range[Length[theList]], for instance. Given such an embedding, any > probability measure on the original set implies a distribution function, and > vice-versa. >> >> Anyway, the OP apparently wanted a sampling function, like Random[], which > doesn't require computing a distribution function at all. He already knew > (and described in his post) how to calculate relative frequencies. >> >> Bobby >> >> On Thu, 2 Sep 2004 04:34:45 -0400 (EDT), Tomas Garza > <tgarza01 at prodigy.net.mx> wrote: >> >> >> From a formal point of view, a distribution function is defined on the >> > reals. You can't, therefore, define it on lists of two, three, or more >> > symbols. A frequency function, on the other hand, may be defined on any > set >> > of events. But, then, it is rather trivial for your problem: once you > have >> > your list distpro, just divide each value in the list by the sum of all > the >> > values, and that's it. Or, maybe, I misunderstood your question? >> > >> > Tomas Garza >> > Mexico City >> > ----- Original Message ----- >> > From: "János" <janos.lobb at yale.edu> To: mathgroup at smc.vnet.net >> > To: mathgroup at smc.vnet.net >> > Subject: [mg50437] [mg50411] [mg50383] newbie is looking for a customDistribution > function >> > >> > >> >> Hi, >> >> >> >> I looked for it in the archives, but found none. I am looking for ways >> >> to create a custom distribution, which I can call as a function. Here >> >> is an example for illustration. Let's say I have a list created from a >> >> 4 elements alphabet {a,b,c,d}: >> >> >> >> In[1]:= >> >> lst={a,a,b,c,a,d,a,c,c,a} >> >> >> >> Out[1]= >> >> {a,a,b,c,a,d,a,c,c,a} >> >> >> >> Distribute gives me - thanks David Park - all the two element >> >> combinations of {a,b,c,d} >> >> >> >> In[11]:= >> >> twocombs=Distribute[Table[{a,b,c,d},{2}],List] >> >> >> >> Out[11]= >> >> > {{a,a},{a,b},{a,c},{a,d},{b,a},{b,b},{b,c},{b,d},{c,a},{c,b},{c,c},{c,d} >> >> ,{ >> >> d,a},{d,b},{d,c},{d,d}} >> >> >> >> I can count the occurrence of an element of twocombs in lst with the >> >> following function: >> >> >> >> occuranceCount[x_List] := Count[Partition[lst, 2, 1], x] >> >> >> >> Mapping this function over twocombs gives me the number of occurances >> >> of elements of twocombs in lst: >> >> >> >> In[12]:= >> >> distro=Map[occuranceCount,twocombs] >> >> >> >> Out[12]= >> >> {1,1,1,1,0,0,1,0,2,0,1,0,1,0,0,0} >> >> >> >> It shows that for example {c,a} occurs twice, {d,a} occurs once and >> >> {d,c} or {d,d} never occur. >> >> >> >> Now, I would like to create a distribution function called >> >> twocombsLstDistribution which I could call and it would give me back >> >> elements of twocombs with the probability as they occur in distro, that >> >> is for on average I would get twice as much {c,a}s as {d,a}s and never >> >> get {d.c} or {d,d}. >> >> >> >> How can I craft that ? >> >> >> >> /Of course I need it for an arbitrary but finite length string lst over >> >> a fixed length alphabet {a,b,c,d,....} for k-length elements of kcombs, >> >> and it has to be super fast :). My real lst is between 30,000 and >> >> 70,000 element long over a four element alphabet and I am looking for k >> >> between 5 and a few hundred. / >> >> >> >> Thanks ahead, >> >> János >> >> ------------------------------------------------- >> >> People never lie so much as after a >> >> hunt, during a war or before an election >> >> - Otto von Bismarck - >> >> >> >> >> > >> > >> > >> > >> >> >> >> -- >> DrBob at bigfoot.com >> www.eclecticdreams.net >> > > > > > -- DrBob at bigfoot.com www.eclecticdreams.net

**References**:**newbie is looking for a customDistribution function***From:*János <janos.lobb@yale.edu>