Thread overview
RangeExtra 10^-20
Apr 25, 2009
dsimcha
Apr 25, 2009
Simen Kjaeraas
Apr 25, 2009
Daniel Keep
Apr 25, 2009
dsimcha
Apr 25, 2009
dsimcha
May 09, 2009
davidl
April 25, 2009
RangeExtra version 10^-20 is officially out.  It consists of a small and
hopefully growing number of ranges that didn't make it into the new Phobos
that I've gotten working reasonably well and I feel eventually belong in Phobos.

Docs / What's there: http://cis.jhu.edu/~dsimcha/rangeextra.html

Code: http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d

License:
Dual licensed, Phobos license or BSD (Tango style).
April 25, 2009
dsimcha wrote:

> RangeExtra version 10^-20 is officially out.  It consists of a small and
> hopefully growing number of ranges that didn't make it into the new Phobos
> that I've gotten working reasonably well and I feel eventually belong in Phobos.
>
> Docs / What's there:
> http://cis.jhu.edu/~dsimcha/rangeextra.html
>
> Code:
> http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
>
> License:
> Dual licensed, Phobos license or BSD (Tango style).

I had hoped reindex would give me access to true 'random' access ranges, but it seems this does not work:

 auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );

:p
April 25, 2009

Simen Kjaeraas wrote:
> dsimcha wrote:
> 
>> RangeExtra version 10^-20 is officially out.  It consists of a small and
>> hopefully growing number of ranges that didn't make it into the new
>> Phobos
>> that I've gotten working reasonably well and I feel eventually belong
>> in Phobos.
>>
>> Docs / What's there: http://cis.jhu.edu/~dsimcha/rangeextra.html
>>
>> Code: http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
>>
>>
>> License:
>> Dual licensed, Phobos license or BSD (Tango style).
> 
> I had hoped reindex would give me access to true 'random' access ranges, but it seems this does not work:
> 
>  auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
> 
> :p

If I had to take a guess, I'd say it was because "uniform" isn't defined in the context of reindex.  Maybe this:

import std.random;

void foo()
{
    auto b = reindex!((i){ return uniform(0,5); })( [0,1,2,3,40.dup );
}

I don't think there's any way to get the length.

  -- Daniel
April 25, 2009
== Quote from Simen Kjaeraas (simen.kjaras@gmail.com)'s article
> dsimcha wrote:
> > RangeExtra version 10^-20 is officially out.  It consists of a small and
> > hopefully growing number of ranges that didn't make it into the new
> > Phobos
> > that I've gotten working reasonably well and I feel eventually belong in
> > Phobos.
> >
> > Docs / What's there: http://cis.jhu.edu/~dsimcha/rangeextra.html
> >
> > Code: http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
> >
> > License:
> > Dual licensed, Phobos license or BSD (Tango style).
> I had hoped reindex would give me access to true 'random' access ranges, but it
seems this does not work:
>   auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
> :p

Very cool idea.  Nothing like what I had in mind as a use case for Reindex, but half the fun of generic programming is seeing stuff get used for things you hadn't anticipated.

I spent some time trying, and for some reason I can't for the life of me get this example to work, or even the one where the length is hard-coded.  It may be some obscure compiler bug, because I'm just getting weird inscrutable error messages and I can't really figure out where they're coming from.

On the other hand, I really like the idea of a with-replacement random sampling primitive.  This sounds like it belongs in RandomCover.  Maybe Andrei can extend RandomCover (which already samples w/o replacement) to include a replacement parameter.  RandomCover w/ replacement == false would do what it does now.  If replacement == true, it would be an infinite range that samples with replacement.
April 25, 2009
== Quote from dsimcha (dsimcha@yahoo.com)'s article
> == Quote from Simen Kjaeraas (simen.kjaras@gmail.com)'s article
> > dsimcha wrote:
> > > RangeExtra version 10^-20 is officially out.  It consists of a small and
> > > hopefully growing number of ranges that didn't make it into the new
> > > Phobos
> > > that I've gotten working reasonably well and I feel eventually belong in
> > > Phobos.
> > >
> > > Docs / What's there: http://cis.jhu.edu/~dsimcha/rangeextra.html
> > >
> > > Code: http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
> > >
> > > License:
> > > Dual licensed, Phobos license or BSD (Tango style).
> > I had hoped reindex would give me access to true 'random' access ranges, but it
> seems this does not work:
> >   auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
> > :p

> On the other hand, I really like the idea of a with-replacement random sampling primitive.  This sounds like it belongs in RandomCover.  Maybe Andrei can extend RandomCover (which already samples w/o replacement) to include a replacement parameter.  RandomCover w/ replacement == false would do what it does now.  If replacement == true, it would be an infinite range that samples with replacement.

Here's a first attempt:  I took Andrei's RandomCover, fixed bug 2865 (This version of RandomCover passes basic statistical tests for uniformity of the distribution over the permutation space), and added a template overload to allow sampling with replacement.  It's under the Phobos license to make it as easy as possible to add back to Phobos.  I'll file an enhancement request.

http://dsource.org/projects/scrapple/browser/trunk/rangeextra/randomcover.d
May 09, 2009
在 Sat, 25 Apr 2009 23:40:03 +0800,dsimcha <dsimcha@yahoo.com> 写道:

> == Quote from dsimcha (dsimcha@yahoo.com)'s article
>> == Quote from Simen Kjaeraas (simen.kjaras@gmail.com)'s article
>> > dsimcha wrote:
>> > > RangeExtra version 10^-20 is officially out.  It consists of a  
>> small and
>> > > hopefully growing number of ranges that didn't make it into the new
>> > > Phobos
>> > > that I've gotten working reasonably well and I feel eventually  
>> belong in
>> > > Phobos.
>> > >
>> > > Docs / What's there:
>> > > http://cis.jhu.edu/~dsimcha/rangeextra.html
>> > >
>> > > Code:
>> > >  
>> http://dsource.org/projects/scrapple/browser/trunk/rangeextra/rangeextra.d
>> > >
>> > > License:
>> > > Dual licensed, Phobos license or BSD (Tango style).
>> > I had hoped reindex would give me access to true 'random' access  
>> ranges, but it
>> seems this does not work:
>> >   auto b = reindex!( "uniform( 0, this.length )" )( [0,1,2,3,4].dup );
>> > :p
>
>> On the other hand, I really like the idea of a with-replacement random sampling
>> primitive.  This sounds like it belongs in RandomCover.  Maybe Andrei can extend
>> RandomCover (which already samples w/o replacement) to include a replacement
>> parameter.  RandomCover w/ replacement == false would do what it does now.  If
>> replacement == true, it would be an infinite range that samples with replacement.
>
> Here's a first attempt:  I took Andrei's RandomCover, fixed bug 2865 (This version
> of RandomCover passes basic statistical tests for uniformity of the distribution
> over the permutation space), and added a template overload to allow sampling with
> replacement.  It's under the Phobos license to make it as easy as possible to add
> back to Phobos.  I'll file an enhancement request.
>
> http://dsource.org/projects/scrapple/browser/trunk/rangeextra/randomcover.d

Looking forward to it!

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/