Author |
Message |
bachus

Joined: Feb 29, 2004 Posts: 2922 Location: Up in that tree over there.
Audio files: 5
|
Posted: Sun Sep 18, 2005 2:03 pm Post subject:
triangular distribution |
 |
|
I needed a triangular distribution random number generator the other day and went looking for source code on the net and eventually came up with this:
http://peabody.sapp.org/class/dmp2/lab/whitenoise/
The code for the generalized triangular distribution random number generator was very buggy and didn’t produce anything like a triangular distribution. I’ve emailed the author to that effect, and perhaps he’ll fix it.
Anyway I fixed and rewrote it and added an integer form and an acuity parameter and added them to my random number generator class. I’ve attached the files for that class for any one to use. (I haven’t tested the __int64 form, h(), yet so it may not work)
The only disadvantage is that there is no way to provide independent streams because of the way the state vector of the Mersenne Twister Random Number Generator was implemented by Jasper Bedaux—see the header file credits. I will fix that eventually. BTW this compiles and runs under VC++6.0
If some kind soul has the code for an integer version of a generalized gaussian distribution and would like to share that I would be very grateful.
Description: |
|
 Download (listen) |
Filename: |
Stochast.h |
Filesize: |
8.77 KB |
Downloaded: |
520 Time(s) |
Description: |
|
 Download (listen) |
Filename: |
Stochast.cpp |
Filesize: |
10.52 KB |
Downloaded: |
502 Time(s) |
_________________ The question is not whether they can talk or reason, but whether they can suffer. -- Jeremy Bentham |
|
Back to top
|
|
 |
jksuperstar

Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18
|
Posted: Sun Sep 18, 2005 3:05 pm Post subject:
|
 |
|
GNU has a library for this, you might get a lot of use out of it, if your looking for lots of types of random variables. I think it is randist.h or similar.
(after googling) This is what I was thinking about:
http://www.gnu.org/software/gsl/
The GNU Scientific Library. Since it's open-source, you could grab any parts of it for your own use. |
|
Back to top
|
|
 |
ian-s

Joined: Apr 01, 2004 Posts: 2672 Location: Auckland, New Zealand
Audio files: 42
G2 patch files: 626
|
Posted: Sun Sep 18, 2005 3:47 pm Post subject:
|
 |
|
CMATH.C from the csound source has lots of random gens |
|
Back to top
|
|
 |
bachus

Joined: Feb 29, 2004 Posts: 2922 Location: Up in that tree over there.
Audio files: 5
|
Posted: Sun Sep 18, 2005 5:44 pm Post subject:
|
 |
|
Thanks for the tips.
I had actually started out searching the GSL for the triangular distribution and did not find it there. I just checked again to see if I had missed it and I still don’t find it. But stix is not exactly a strong point for me so perhaps it goes by a more esoteric name? (GSL is eat up with distributions I never heard of.) Anyone know?
Anyway the GSL is indeed an excellent source and I wish I had known about it before I had started the Stochast class.
As for the gaussian what I need is a function that has the same call format as the triangular. I.e. it would look like:
int Stoch::iGaussian(int lower, int max, int upper, double acuity)
So far I haven’t found anything like it so I may eventually have to dig out the math books and see if I can figure out how to get there from the standard implementations ..ho-hum. But I keep hoping it will just fall into my lap.
Haven’t dug through the Csound math library yet, will try that before I give up.
Again thanks. _________________ The question is not whether they can talk or reason, but whether they can suffer. -- Jeremy Bentham |
|
Back to top
|
|
 |
|