From: rickman on
On Nov 17, 9:33 am, Vladimir Vassilevsky <nos...(a)nowhere.com> wrote:
>
> Abandon this task. It is not for the sorrow programmers like you.
>
> Vladimir Vassilevsky
> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com


Even with all the spam I have to parse through on the Google groups
page, I have never considered going back to a newsreader. But this
might just be a good reason, to be able to killfile someone... I
wonder who...

But then I am just feeding the troll, so maybe I should killfile
myself...

Rick
From: Jon Kirwan on
On Wed, 18 Nov 2009 12:18:20 -0800 (PST), rickman <gnuarm(a)gmail.com>
wrote:

>On Nov 17, 9:33�am, Vladimir Vassilevsky <nos...(a)nowhere.com> wrote:
>>
>> Abandon this task. It is not for the sorrow programmers like you.
>>
>> Vladimir Vassilevsky
>> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com
>
>Even with all the spam I have to parse through on the Google groups
>page, I have never considered going back to a newsreader. But this
>might just be a good reason, to be able to killfile someone... I
>wonder who...
>
>But then I am just feeding the troll, so maybe I should killfile
>myself...
>
>Rick

I've wondered why he bothers. It doesn't often appear to be for
teaching anyone.

He has a point if you take his assumptions. It's kind of a sad
comment on the general state of embedded programming affairs, if you
assume the OP is someone who is charged with the engineering of a
system of RF boards and is then asking about how to generate a random
delay. The assumption may be false, though. It's possible this is
someone who knows their application space well but isn't an engineer
-- more of an integrator?? -- and who could use a gentle clue. It's
also possible that the OP is asking for practical experience and just
stating it poorly. Still, it does beg a few questions.

Since I've now bothered writing at all, the OP may google up "linear
congruential generator" (LCG) and keep in mind also the basic idea of
a linear expression that yields something within a specified range,
X+(Y-X)*(R-Rmin)/(Rmax-Rmin+1), where the X and Y are his own values
from his post and the Rmax and Rmin are the minimum and maximum values
that the LCG produces. Rmin is often 0, but not always. The
expression assumes real numbers. If integers are exclusively used,
finding an LCG with a nice (Rmax-Rmin+1)=2^N, with N a positive
integer, might help somewhat. Scaling to produce a desired precision
in milliseconds may also be warranted. Also, I very much support
another poster's comment about reading Donald Knuth's volume on
Seminumerical Algorithms from the early 1970's (I completely read his
three books, cover to cover including the long discussions on tape
sorting, when they came out and they added a lot to my earlier
education.)

Jon
From: rickman on
On Nov 18, 5:43 pm, Jon Kirwan <j...(a)infinitefactors.org> wrote:
> On Wed, 18 Nov 2009 12:18:20 -0800 (PST), rickman <gnu...(a)gmail.com>
> wrote:
>
>
>
> >On Nov 17, 9:33 am, Vladimir Vassilevsky <nos...(a)nowhere.com> wrote:
>
> >> Abandon this task. It is not for the sorrow programmers like you.
>
> >> Vladimir Vassilevsky
> >> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com
>
> >Even with all the spam I have to parse through on the Google groups
> >page, I have never considered going back to a newsreader.  But this
> >might just be a good reason, to be able to killfile someone...  I
> >wonder who...
>
> >But then I am just feeding the troll, so maybe I should killfile
> >myself...
>
> >Rick
>
> I've wondered why he bothers.  It doesn't often appear to be for
> teaching anyone.
>
> He has a point if you take his assumptions.  It's kind of a sad
> comment on the general state of embedded programming affairs, if you
> assume the OP is someone who is charged with the engineering of a
> system of RF boards and is then asking about how to generate a random
> delay.  The assumption may be false, though.  It's possible this is
> someone who knows their application space well but isn't an engineer
> -- more of an integrator?? -- and who could use a gentle clue.  It's
> also possible that the OP is asking for practical experience and just
> stating it poorly.  Still, it does beg a few questions.
>
> Since I've now bothered writing at all, the OP may google up "linear
> congruential generator" (LCG) and keep in mind also the basic idea of
> a linear expression that yields something within a specified range,
> X+(Y-X)*(R-Rmin)/(Rmax-Rmin+1), where the X and Y are his own values
> from his post and the Rmax and Rmin are the minimum and maximum values
> that the LCG produces.  Rmin is often 0, but not always.  The
> expression assumes real numbers.  If integers are exclusively used,
> finding an LCG with a nice (Rmax-Rmin+1)=2^N, with N a positive
> integer, might help somewhat.  Scaling to produce a desired precision
> in milliseconds may also be warranted.  Also, I very much support
> another poster's comment about reading Donald Knuth's volume on
> Seminumerical Algorithms from the early 1970's (I completely read his
> three books, cover to cover including the long discussions on tape
> sorting, when they came out and they added a lot to my earlier
> education.)
>
> Jon

I don't care what the issue is, VV's approach is rude and accomplishes
nothing. I wish he would just go away unless he is willing to
actually help someone. There are any number of things I am ignorant
about in the field of EE which I have been earning a living in for 30
years. Does that make me stupid? That is why we are here for the
most part I think, to learn things we don't know.

I know that school taught me a lot of basics, but I have learned all
the practical stuff while working. Does that mean my schooling was
lacking?

There are any number of reasons why someone posts angry replies.
Regardless, they reflect badly on the poster and annoy the rest of
us.

Rick
From: vladitx on
On Nov 18, 3:30 pm, Hans-Bernhard Bröker <HBBroe...(a)t-online.de>
wrote:
> vladitx wrote:
> > On Nov 17, 3:06 pm, "Go Rf" <R...(a)Rf.org> wrote:
>
> >> I need a function, when called returns a pseudo random number between X and
> >> Y.
>
> > For the interval [X, Y), assuming _unsigned_ integers and 'C' syntax:
>
> > random = X + (rnd() % (Y - X));
>
> An elegant formula, isn't it?

I am glad there is enough sarcasm in Usenet to keep boredom away.

>  Unfortunately it has a serious problem:
> the result doesn't have the qualities usually requested from it.

It fits the OP's request which I had explicitly commented on.

>  It's
> not uniformly distributed unless (Y-X) just so happens to exactly divide
> the range of the random number generator.

Of course it doesn't guarantee uniform distribution for any choice of
parameters, I didn't even wanted it to. :-)
It's the most basic stuff you can do with - this and some PRNG of your
choice. And you get what you paid for.

There is enough literature on PRNGs, in case OP wants to know more.
From: Jon Kirwan on
On Wed, 18 Nov 2009 15:23:39 -0800 (PST), rickman <gnuarm(a)gmail.com>
wrote:

>On Nov 18, 5:43�pm, Jon Kirwan <j...(a)infinitefactors.org> wrote:
>> On Wed, 18 Nov 2009 12:18:20 -0800 (PST), rickman <gnu...(a)gmail.com>
>> wrote:
>>
>>
>>
>> >On Nov 17, 9:33�am, Vladimir Vassilevsky <nos...(a)nowhere.com> wrote:
>>
>> >> Abandon this task. It is not for the sorrow programmers like you.
>>
>> >> Vladimir Vassilevsky
>> >> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com
>>
>> >Even with all the spam I have to parse through on the Google groups
>> >page, I have never considered going back to a newsreader. �But this
>> >might just be a good reason, to be able to killfile someone... �I
>> >wonder who...
>>
>> >But then I am just feeding the troll, so maybe I should killfile
>> >myself...
>>
>> >Rick
>>
>> I've wondered why he bothers. �It doesn't often appear to be for
>> teaching anyone.
>>
>> He has a point if you take his assumptions. �It's kind of a sad
>> comment on the general state of embedded programming affairs, if you
>> assume the OP is someone who is charged with the engineering of a
>> system of RF boards and is then asking about how to generate a random
>> delay. �The assumption may be false, though. �It's possible this is
>> someone who knows their application space well but isn't an engineer
>> -- more of an integrator?? -- and who could use a gentle clue. �It's
>> also possible that the OP is asking for practical experience and just
>> stating it poorly. �Still, it does beg a few questions.
>>
>> Since I've now bothered writing at all, the OP may google up "linear
>> congruential generator" (LCG) and keep in mind also the basic idea of
>> a linear expression that yields something within a specified range,
>> X+(Y-X)*(R-Rmin)/(Rmax-Rmin+1), where the X and Y are his own values
>> from his post and the Rmax and Rmin are the minimum and maximum values
>> that the LCG produces. �Rmin is often 0, but not always. �The
>> expression assumes real numbers. �If integers are exclusively used,
>> finding an LCG with a nice (Rmax-Rmin+1)=2^N, with N a positive
>> integer, might help somewhat. �Scaling to produce a desired precision
>> in milliseconds may also be warranted. �Also, I very much support
>> another poster's comment about reading Donald Knuth's volume on
>> Seminumerical Algorithms from the early 1970's (I completely read his
>> three books, cover to cover including the long discussions on tape
>> sorting, when they came out and they added a lot to my earlier
>> education.)
>>
>> Jon
>
>I don't care what the issue is, VV's approach is rude and accomplishes
>nothing. I wish he would just go away unless he is willing to
>actually help someone. There are any number of things I am ignorant
>about in the field of EE which I have been earning a living in for 30
>years. Does that make me stupid? That is why we are here for the
>most part I think, to learn things we don't know.
>
>I know that school taught me a lot of basics, but I have learned all
>the practical stuff while working. Does that mean my schooling was
>lacking?
>
>There are any number of reasons why someone posts angry replies.
>Regardless, they reflect badly on the poster and annoy the rest of
>us.

Gotcha, Rick, and understood. Largely agreed.

* While I'm at it, to the OP: You can combine the LCG's equation with
the linear one used to provide a chosen range into a single linear
expression with the same operation count as only one would require.
Some care may be needed, though, to retain bits appropriately.

Jon