Hi EVerybody,

I would like to generate a random number from chi-square distribution. But I can not find any class that is able to do that.

Thanks in advance

Printable View

- 04-15-2009, 09:50 PMaeo3[SOLVED] How to generate a random number from chi-square
Hi EVerybody,

I would like to generate a random number from chi-square distribution. But I can not find any class that is able to do that.

Thanks in advance - 04-15-2009, 10:14 PMFubarable
This isn't exactly a Swing question (this is the Swing forum). Have you had a look at Google first? What have you found there? Likely you'll need to download the chi-square data tables from some source. SourceForge may have some useful public domain code for this, but again, likely you best bet will be Google. Best of luck.

- 04-16-2009, 12:29 AMOrangeDog
I think apache have code for that in org.apache.commons.math

- 04-16-2009, 01:42 AMCJSLMANhhhmmm... interesting...
It's been like a million years since I've had anything to do with chi-square. Here are some ideas...

Create a table (like Fubarable commented) or generate the values in the program and (either way) stuff the values in an array. Then randomly generate array indexes and get/pull the elements/values at those indexes.

Luck,

CJSL