Re: [go-nuts] Re: Random Number Generation in a given range

2017-07-10 Thread alok . singh
yep you are right ! fixed it thanks 
https://github.com/alok87/goutils/commit/9f5f19a65eedf1bc9be82ec3f3b42c92142b2b8e


On Monday, July 10, 2017 at 8:15:13 PM UTC+5:30, Jan Mercl wrote:
>
>
> On Mon, Jul 10, 2017 at 4:41 PM Alok Kumar Singh  > wrote:
>
> > in my usecasei use this to generate random slice everytime 
> > dont want the same result
> > using it to test my algos
>
> For that you need one only call to Seed at init().
>
> -- 
>
> -j
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Random Number Generation in a given range

2017-07-10 Thread Jan Mercl
On Mon, Jul 10, 2017 at 4:41 PM Alok Kumar Singh 
wrote:

> in my usecasei use this to generate random slice everytime
> dont want the same result
> using it to test my algos

For that you need one only call to Seed at init().

-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Random Number Generation in a given range

2017-07-10 Thread Sebastien Binet
Alok,

On Mon, Jul 10, 2017 at 3:04 PM, Alok Kumar Singh 
wrote:

> I have fixed it thanks
>

I wouldn't recommend using rand.Seed as you do: this defeats any attempt at
getting reproductible results.

-s

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Random Number Generation in a given range

2017-07-10 Thread Alok Kumar Singh
I have fixed it thanks

On Mon, Jul 10, 2017 at 9:54 AM, peterGo  wrote:

> Alok,
>
> Your import path "github.com/alok87/goutils/random" is not valid for "go
> get". The source is at "github.com/alok87/goutils/pkg/random".
>
> You write "for { rand.Seed(); rand.Intn(); }". Therefore, the range of
> values is not random.
>
> You write "arr[r] = rand.Intn(max) + min" which is incorrect.
>
> And so on.
>
> Peter
>
>
> On Sunday, July 9, 2017 at 3:02:43 PM UTC-4, alok@practo.com wrote:
>>
>> A python like range utility which can be used for this
>> https://github.com/alok87/goutils/blob/master/pkg/random/random.go
>> ```random.RangeInt(2, 100, 3)```
>>
>> On Wednesday, March 28, 2012 at 5:43:55 AM UTC+5:30, Guillermo Estrada
>> wrote:
>>>
>>> Hi, I've been reading some posts but I still have the same question.
>>>
>>> I need to generate a random number between a min and a max value of
>>> floats (Float64) for example:
>>>
>>> random(-0.001, 0.001)
>>>
>>> Is there any way pkg "math/rand" could do this using the Normal
>>> Distribution or such? Most Random generation on the pkg works in [0.0,1.0)
>>> The closest I found is:
>>>
>>> func (*Rand) NormFloat64
>>> 
>>> But I need a way to clamp that range into my own, any ideas? Thnx in
>>> advance!
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/_M-8hRpQs84/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Regards,

Alok Kumar Singh


Platform Engineering

+ 91 9880121029

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Random Number Generation in a given range

2017-07-09 Thread peterGo
Alok,

Your import path "github.com/alok87/goutils/random" is not valid for "go 
get". The source is at "github.com/alok87/goutils/pkg/random".

You write "for { rand.Seed(); rand.Intn(); }". Therefore, the range of 
values is not random.

You write "arr[r] = rand.Intn(max) + min" which is incorrect.

And so on.

Peter

On Sunday, July 9, 2017 at 3:02:43 PM UTC-4, alok@practo.com wrote:
>
> A python like range utility which can be used for this
> https://github.com/alok87/goutils/blob/master/pkg/random/random.go
> ```random.RangeInt(2, 100, 3)```
>
> On Wednesday, March 28, 2012 at 5:43:55 AM UTC+5:30, Guillermo Estrada 
> wrote:
>>
>> Hi, I've been reading some posts but I still have the same question.
>>
>> I need to generate a random number between a min and a max value of 
>> floats (Float64) for example:
>>
>> random(-0.001, 0.001)
>>
>> Is there any way pkg "math/rand" could do this using the Normal 
>> Distribution or such? Most Random generation on the pkg works in [0.0,1.0)
>> The closest I found is:
>>
>> func (*Rand) NormFloat64 
>> 
>> But I need a way to clamp that range into my own, any ideas? Thnx in 
>> advance!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Random Number Generation in a given range

2017-07-09 Thread alok . singh
A python like range utility which can be used for this
https://github.com/alok87/goutils/blob/master/pkg/random/random.go
```random.RangeInt(2, 100, 3)```

On Wednesday, March 28, 2012 at 5:43:55 AM UTC+5:30, Guillermo Estrada 
wrote:
>
> Hi, I've been reading some posts but I still have the same question.
>
> I need to generate a random number between a min and a max value of floats 
> (Float64) for example:
>
> random(-0.001, 0.001)
>
> Is there any way pkg "math/rand" could do this using the Normal 
> Distribution or such? Most Random generation on the pkg works in [0.0,1.0)
> The closest I found is:
>
> func (*Rand) NormFloat64 
> 
> But I need a way to clamp that range into my own, any ideas? Thnx in 
> advance!
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.