Re: [PD] vanilla solution for random float

2016-06-02 Thread IOhannes m zmoelnig
On 2016-06-02 09:25, Claude Heiland-Allen wrote:
> On 02/06/16 08:09, IOhannes m zmölnig wrote:
>> On 05/31/2016 05:50 PM, IOhannes m zmoelnig wrote:
>>> i really like the powers of the new [osc*] objects for these kind of
>>> things.
>>
>> here's an updated example, that properly generates numbers in to 0..1
>> range.
>>
>> it has full 24bit of (pseudo) randomness.
> 
> But the distribution is not uniform (lower third is twice as likely as
> the upper two thirds of the range).  See attached for a test.

sigh indeed.
it also misses a few values altogether.

so here's an update which i think has these issues fixed.
at least your probability plot shows no anomalies, and it now uses all
23bit of the mantissa for randomness rather than just 20bit.

fgasdrm
IOhannes

#N canvas 1285 163 778 607 10;
#X obj 170 293 oscparse;
#X obj 170 269 list prepend 47 97 0 0 44 102 0 0;
#X obj 170 315 list split 1;
#X obj 170 139 t b b b b;
#X obj 170 117 inlet;
#X obj 210 387 outlet;
#X obj 170 235 pack 63 0 0 0;
#X obj 199 205 | 128;
#X obj 210 341 - 1;
#X obj 228 187 random 256;
#X obj 259 209 random 256;
#X obj 199 163 random 128;
#X connect 0 0 2 0;
#X connect 1 0 0 0;
#X connect 2 1 8 0;
#X connect 3 0 6 0;
#X connect 3 1 11 0;
#X connect 3 2 9 0;
#X connect 3 3 10 0;
#X connect 4 0 3 0;
#X connect 6 0 1 0;
#X connect 7 0 6 1;
#X connect 8 0 5 0;
#X connect 9 0 6 2;
#X connect 10 0 6 3;
#X connect 11 0 7 0;


signature.asc
Description: OpenPGP digital signature
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-06-02 Thread Claude Heiland-Allen

On 02/06/16 08:09, IOhannes m zmölnig wrote:

On 05/31/2016 05:50 PM, IOhannes m zmoelnig wrote:

i really like the powers of the new [osc*] objects for these kind of things.


here's an updated example, that properly generates numbers in to 0..1 range.

it has full 24bit of (pseudo) randomness.


But the distribution is not uniform (lower third is twice as likely as 
the upper two thirds of the range).  See attached for a test.



Claude
--
https://mathr.co.uk

#N canvas 1 51 308 317 10;
#X obj 103 91 randF;
#X obj 103 113 * 1000;
#X obj 103 135 int;
#X obj 103 177 tabread \$0-hist;
#X obj 103 199 + 1;
#X obj 103 221 tabwrite \$0-hist;
#X obj 103 157 t f f;
#X obj 41 255 table \$0-hist 1000;
#X obj 76 23 t b b;
#X obj 103 68 until;
#X msg 10 48 normalize 1;
#X obj 10 70 s \$0-hist;
#X obj 78 5 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X msg 106 46 1e+06;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 2 0 6 0;
#X connect 3 0 4 0;
#X connect 4 0 5 0;
#X connect 6 0 3 0;
#X connect 6 1 5 1;
#X connect 8 0 10 0;
#X connect 8 1 13 0;
#X connect 9 0 0 0;
#X connect 10 0 11 0;
#X connect 12 0 8 0;
#X connect 13 0 9 0;
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-06-02 Thread IOhannes m zmölnig
On 06/01/2016 05:08 AM, Alexandre Torres Porres wrote:
> apparently no one knows as it is not documented, but [expr] has a range
> random function, so you can do something like.
> 
> [expr random(0, 1000)/1000.0)]

hmm, how is this different from the following?

[random 1000]
|
[/ 1000]

more importantly, how does this use anything near the "full
floating-point resolution" requested by the OP? (e.g. this random
generator can never generate 0.1234)

dfsamra
IOhannes



signature.asc
Description: OpenPGP digital signature
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-06-02 Thread IOhannes m zmölnig
On 05/31/2016 05:50 PM, IOhannes m zmoelnig wrote:
> On 2016-05-31 17:00, Miller Puckette wrote:
>> I just tried "random 1e8" and "/ 1e8" and it seems to work for me.  If it
>> doens't for you that's a bug I should look at :)
> 
> i really like the powers of the new [osc*] objects for these kind of things.
> 

here's an updated example, that properly generates numbers in to 0..1 range.

it has full 24bit of (pseudo) randomness.

gfmards
IOhannes

#N canvas 380 157 778 607 10;
#X obj 170 293 oscparse;
#X obj 170 269 list prepend 47 97 0 0 44 102 0 0;
#X obj 199 163 random 255;
#X obj 228 187 random 255;
#X obj 170 315 list split 1;
#X obj 170 139 t b b b b;
#X obj 258 209 random 255;
#X obj 170 117 inlet;
#X obj 210 387 outlet;
#X obj 210 341 - 0.5;
#X obj 210 363 / 1.5;
#X obj 170 235 pack 63 0 0 0;
#X connect 0 0 4 0;
#X connect 1 0 0 0;
#X connect 2 0 11 1;
#X connect 3 0 11 2;
#X connect 4 1 9 0;
#X connect 5 0 11 0;
#X connect 5 1 2 0;
#X connect 5 2 3 0;
#X connect 5 3 6 0;
#X connect 6 0 11 3;
#X connect 7 0 5 0;
#X connect 9 0 10 0;
#X connect 10 0 8 0;
#X connect 11 0 1 0;


signature.asc
Description: OpenPGP digital signature
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-06-01 Thread Raphaël Ilias
Thanks everybody for your suggestions,
I'll stay with the "full resolution" random 1<<24 since i only want uniform
random, but i'll give a try to the mentionned externals.

all best,

Raphaël

2016-06-01 9:17 GMT+02:00 Lorenzo Sutton :

> Hi,
>
> On 31/05/2016 16:44, Raphaël Ilias wrote:
>
>> Hello list,
>>
>> I want to do a simple task : pick a random float in a defined range
>> (let's say between 0.0 and 1.0).
>>
> [...]
>
>> I generally prefer to make vanilla abstractions.
>>
>>
> If you're after more random randomness you could search online for free
> random (or noise) sources, load them into an array, normalize 0.0 to 1.0
> and read the array.
> Of course this may or may not fit your scenario depending on e.g. the rate
> at which you need to get a new random number etc.
>
> Lorenzo.
>
>
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-06-01 Thread Lorenzo Sutton

Hi,

On 31/05/2016 16:44, Raphaël Ilias wrote:

Hello list,

I want to do a simple task : pick a random float in a defined range
(let's say between 0.0 and 1.0).

[...]

I generally prefer to make vanilla abstractions.



If you're after more random randomness you could search online for free 
random (or noise) sources, load them into an array, normalize 0.0 to 1.0 
and read the array.
Of course this may or may not fit your scenario depending on e.g. the 
rate at which you need to get a new random number etc.


Lorenzo.

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread Alexandre Torres Porres
apparently no one knows as it is not documented, but [expr] has a range
random function, so you can do something like.

[expr random(0, 1000)/1000.0)]

just bang it

cheers

2016-05-31 11:44 GMT-03:00 Raphaël Ilias :

> Hello list,
>
> I want to do a simple task : pick a random float in a defined range (let's
> say between 0.0 and 1.0).
> I know there are this kind of objects in external libraries (something
> like [randomF] if remember), but since the collapse of Pd-Extended, I
> generally prefer to make vanilla abstractions.
>
> The two solutions i foresee are :
>
> solution #1 :
>
> [random 1e+06]
>  |
> [/ 1e+06]
>
> but this way, it doesn't use the full floating-point resolution ?... and
> going over that range (like 1e_07) will result in errors (outputs 0) I
> guess because of floating-point complexity.
>
>
> # solution #2 :
>
> [noise~]
>   |
> [snapshot~]
>
> but this won't work if DSP/audio is turned off.
>
>
>
> so I wondered if there are other vanilla and efficient solutions?
> ...or if I just have to get the external from deken... ?
> :)
>
> thanks,
>
> Raphaël
>
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread Fred Jan Kraan

Hi Raphaël,


Hello list,

I want to do a simple task : pick a random float in a defined range
(let's say between 0.0 and 1.0).
I know there are this kind of objects in external libraries (something
like [randomF] if remember), but since the collapse of Pd-Extended, I
generally prefer to make vanilla abstractions.


This is the best solution from educational point of view, and the most 
fun :-)




so I wondered if there are other vanilla and efficient solutions?
...or if I just have to get the external from deken... ?
:)


The deken external library maxlib contains a collection of random number 
generators (see maxlib-help.pd for an overview). The usual range is 0-1, 
so you can multiply as you wish.




thanks,

Raphaël


Greetings & success,

Fred Jan

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread IOhannes m zmoelnig
On 2016-05-31 17:00, Miller Puckette wrote:
> I just tried "random 1e8" and "/ 1e8" and it seems to work for me.  If it
> doens't for you that's a bug I should look at :)

i really like the powers of the new [osc*] objects for these kind of things.

it allows me to do seemingly trivial things in complicated manners.

fgmasr
IOhannes
#N canvas 379 357 778 607 10;
#X obj 169 283 oscparse;
#X obj 169 259 list prepend 47 97 0 0 44 102 0 0;
#X obj 229 124 random 255;
#X obj 289 103 random 255;
#X obj 169 305 list split 1;
#X obj 170 79 t b b b b;
#X obj 310 122 random 255;
#X obj 170 101 random 255;
#X obj 170 123 & 63;
#X obj 171 195 pack 0 0 0 0;
#X obj 170 145 | 32;
#X obj 171 217 t l l;
#X obj 172 57 inlet;
#X obj 208 338 outlet;
#X connect 0 0 4 0;
#X connect 1 0 0 0;
#X connect 2 0 9 1;
#X connect 3 0 9 2;
#X connect 4 1 13 0;
#X connect 5 0 7 0;
#X connect 5 1 2 0;
#X connect 5 2 3 0;
#X connect 5 3 6 0;
#X connect 6 0 9 3;
#X connect 7 0 8 0;
#X connect 8 0 10 0;
#X connect 9 0 11 0;
#X connect 10 0 9 0;
#X connect 11 0 1 0;
#X connect 12 0 5 0;


signature.asc
Description: OpenPGP digital signature
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread Raphaël Ilias
Ok thanks for pointing out the actual decimal precision limit, I get it,
according to my understanding of 32-bit floats type.

I was also wondering why this kind of common function isn't implemented in
vanilla, in the form of an objet, or even as standardized abstraction (like
the list-abs ?) ?
 Because, it's like everyone has to :
- download an external library (and get other extra objects)
- or build it's own abstraction which make patch less "standardized"
(different names, in/outlets) and subject to errors in conception (like
here, not using maximum range).

I know this might be a delicate debate, but I feel like this kind of
function (like "floating-point random" but one  could find other examples)
could be provided as abstractions, since it's already useable but anyone
who wants to learn can check the inner patch ?

Don't want to start a messy troll, but at least IMHO this feature really
misses in vanilla,

++

Raphaël



2016-05-31 17:12 GMT+02:00 Matt Barber :

> Your maximum [random] resolution is 2^24. You can send [1 (—[<< 24] to the
> right inlet of [random] and the right inlet of [/ ] and you'll have the max
> float resolution (assuming uniform distribution) between 0 and 1.
>
> On Tue, May 31, 2016 at 10:44 AM, Raphaël Ilias 
> wrote:
>
>> Hello list,
>>
>> I want to do a simple task : pick a random float in a defined range
>> (let's say between 0.0 and 1.0).
>> I know there are this kind of objects in external libraries (something
>> like [randomF] if remember), but since the collapse of Pd-Extended, I
>> generally prefer to make vanilla abstractions.
>>
>> The two solutions i foresee are :
>>
>> solution #1 :
>>
>> [random 1e+06]
>>  |
>> [/ 1e+06]
>>
>> but this way, it doesn't use the full floating-point resolution ?... and
>> going over that range (like 1e_07) will result in errors (outputs 0) I
>> guess because of floating-point complexity.
>>
>>
>> # solution #2 :
>>
>> [noise~]
>>   |
>> [snapshot~]
>>
>> but this won't work if DSP/audio is turned off.
>>
>>
>>
>> so I wondered if there are other vanilla and efficient solutions?
>> ...or if I just have to get the external from deken... ?
>> :)
>>
>> thanks,
>>
>> Raphaël
>>
>> ___
>> Pd-list@lists.iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> https://lists.puredata.info/listinfo/pd-list
>>
>>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread Matt Barber
Your maximum [random] resolution is 2^24. You can send [1 (—[<< 24] to the
right inlet of [random] and the right inlet of [/ ] and you'll have the max
float resolution (assuming uniform distribution) between 0 and 1.

On Tue, May 31, 2016 at 10:44 AM, Raphaël Ilias 
wrote:

> Hello list,
>
> I want to do a simple task : pick a random float in a defined range (let's
> say between 0.0 and 1.0).
> I know there are this kind of objects in external libraries (something
> like [randomF] if remember), but since the collapse of Pd-Extended, I
> generally prefer to make vanilla abstractions.
>
> The two solutions i foresee are :
>
> solution #1 :
>
> [random 1e+06]
>  |
> [/ 1e+06]
>
> but this way, it doesn't use the full floating-point resolution ?... and
> going over that range (like 1e_07) will result in errors (outputs 0) I
> guess because of floating-point complexity.
>
>
> # solution #2 :
>
> [noise~]
>   |
> [snapshot~]
>
> but this won't work if DSP/audio is turned off.
>
>
>
> so I wondered if there are other vanilla and efficient solutions?
> ...or if I just have to get the external from deken... ?
> :)
>
> thanks,
>
> Raphaël
>
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread Raphaël Ilias
Sorry my error, I tried :

random 1e+08 / 1e+08

..and it works. Don't know how I got this wrong results.
It evens work until 1e+09, the precision error (that outputs 0) starts from
1e+10.

Is 1e+09 using the full decimal precision of pd's 32-bits floats ?

thanks

Raphaël


2016-05-31 17:00 GMT+02:00 Miller Puckette :

> I just tried "random 1e8" and "/ 1e8" and it seems to work for me.  If it
> doens't for you that's a bug I should look at :)
>
> cheers
> Miller
>
> On Tue, May 31, 2016 at 04:48:59PM +0200, apva...@gmail.com wrote:
> >
> >
> > Sent from my iPhone
> >
> > > On May 31, 2016, at 4:44 PM, Raphaël Ilias 
> wrote:
> > >
> > > Hello list,
> > >
> > > I want to do a simple task : pick a random float in a defined range
> (let's say between 0.0 and 1.0).
> > > I know there are this kind of objects in external libraries (something
> like [randomF] if remember), but since the collapse of Pd-Extended, I
> generally prefer to make vanilla abstractions.
> > >
> > > The two solutions i foresee are :
> > >
> > > solution #1 :
> > >
> > > [random 1e+06]
> > >  |
> > > [/ 1e+06]
> > >
> > > but this way, it doesn't use the full floating-point resolution ?...
> and going over that range (like 1e_07) will result in errors (outputs 0) I
> guess because of floating-point complexity.
> > >
> > >
> > > # solution #2 :
> > >
> > > [noise~]
> > >   |
> > > [snapshot~]
> > >
> > > but this won't work if DSP/audio is turned off.
> > >
> > >
> > >
> > > so I wondered if there are other vanilla and efficient solutions?
> > > ...or if I just have to get the external from deken... ?
> > > :)
> > >
> > > thanks,
> > >
> > > Raphaël
> > > ___
> > > Pd-list@lists.iem.at mailing list
> > > UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
> >
> > ___
> > Pd-list@lists.iem.at mailing list
> > UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread Miller Puckette
I just tried "random 1e8" and "/ 1e8" and it seems to work for me.  If it
doens't for you that's a bug I should look at :)

cheers
Miller

On Tue, May 31, 2016 at 04:48:59PM +0200, apva...@gmail.com wrote:
> 
> 
> Sent from my iPhone
> 
> > On May 31, 2016, at 4:44 PM, Raphaël Ilias  wrote:
> > 
> > Hello list,
> > 
> > I want to do a simple task : pick a random float in a defined range (let's 
> > say between 0.0 and 1.0).
> > I know there are this kind of objects in external libraries (something like 
> > [randomF] if remember), but since the collapse of Pd-Extended, I generally 
> > prefer to make vanilla abstractions.
> > 
> > The two solutions i foresee are : 
> > 
> > solution #1 :
> > 
> > [random 1e+06]
> >  |
> > [/ 1e+06]
> > 
> > but this way, it doesn't use the full floating-point resolution ?... and 
> > going over that range (like 1e_07) will result in errors (outputs 0) I 
> > guess because of floating-point complexity.
> > 
> > 
> > # solution #2 :
> > 
> > [noise~]
> >   |
> > [snapshot~]
> > 
> > but this won't work if DSP/audio is turned off.
> > 
> > 
> > 
> > so I wondered if there are other vanilla and efficient solutions?
> > ...or if I just have to get the external from deken... ?
> > :)
> > 
> > thanks,
> > 
> > Raphaël
> > ___
> > Pd-list@lists.iem.at mailing list
> > UNSUBSCRIBE and account-management -> 
> > https://lists.puredata.info/listinfo/pd-list
> 
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> https://lists.puredata.info/listinfo/pd-list

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] vanilla solution for random float

2016-05-31 Thread apvague


Sent from my iPhone

> On May 31, 2016, at 4:44 PM, Raphaël Ilias  wrote:
> 
> Hello list,
> 
> I want to do a simple task : pick a random float in a defined range (let's 
> say between 0.0 and 1.0).
> I know there are this kind of objects in external libraries (something like 
> [randomF] if remember), but since the collapse of Pd-Extended, I generally 
> prefer to make vanilla abstractions.
> 
> The two solutions i foresee are : 
> 
> solution #1 :
> 
> [random 1e+06]
>  |
> [/ 1e+06]
> 
> but this way, it doesn't use the full floating-point resolution ?... and 
> going over that range (like 1e_07) will result in errors (outputs 0) I guess 
> because of floating-point complexity.
> 
> 
> # solution #2 :
> 
> [noise~]
>   |
> [snapshot~]
> 
> but this won't work if DSP/audio is turned off.
> 
> 
> 
> so I wondered if there are other vanilla and efficient solutions?
> ...or if I just have to get the external from deken... ?
> :)
> 
> thanks,
> 
> Raphaël
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> https://lists.puredata.info/listinfo/pd-list

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list