Qbasicnews.com
May 09, 2021, 01:02:41 AM
 Pages: 1 2 [3] 4
 Author Topic: Statistical Challenge  (Read 22968 times)
oracle
*/-\*

Posts: 3652

 « Reply #30 on: May 06, 2003, 05:37:01 AM »

OK then, I'll check later on neo's code, but now: Do the permutation and combination thingy.
 Logged

na_th_an
*/-\*

Posts: 8244

 « Reply #31 on: May 06, 2003, 08:35:44 AM »

Permutation:

Code:
FUNCTION permutation&(n&, k&)
permutation& = factorial&(n&) / factorial&(n&-k&)
END FUNCTION

Combination:

Code:
FUNCTION combination(n&, k&)
combination& = factorial(n&) / (factorial(n&-k&) * factorial(k&))
END FUNCTION
 Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
oracle
*/-\*

Posts: 3652

 « Reply #32 on: May 06, 2003, 07:00:41 PM »

Good... na_th_an 2 : others 0

Now... statistical deviation. Two functions, one sample and one population.
 Logged

DrV
Na_th_an

Posts: 1553

 « Reply #33 on: May 13, 2003, 06:08:18 PM »

Heh... how about the binomial theorem while you're all at it...
 Logged
oracle
*/-\*

Posts: 3652

 « Reply #34 on: May 13, 2003, 11:41:27 PM »

Yeah... that's the idea. In the end I want to have enough statistical formulae to put in a lib or something, then people who make baseball/other sport games can use the stats lib to generate proper stats...

The Binomial theorem: I can't remember the formula off the top of my head, but I know it has a combination in it and na_th_an has already made that one, so it should be easy. Just do it as a function like the others.

Anyone interested in this lib idea?
 Logged

DrV
Na_th_an

Posts: 1553

 « Reply #35 on: May 15, 2003, 07:55:54 PM »

Binomial theorem:

The (k+1)st term of (a + b) ^ n is:
Code:

factorial(n) / factorial(n - k) / factorial(k) * a ^ (n - k) * b ^ k

A library would be interesting.  Oh, and here's sums of geometric, arithmetic, and infinite geometric sequences:

G:  t1 * (1 - r ^ n) / (1 - r)    r != 1

A:  n * (t1 + tn) / 2

I:  t1 / (1 - r)

where r is the common ratio, t1 is the first term in the sequence, n is the number of terms to sum, and tn is the nth term of the sequence.
 Logged
oracle
*/-\*

Posts: 3652

 « Reply #36 on: May 15, 2003, 08:00:14 PM »

I'll test your Binomial when I get home. Everyone submitting code will get credited, BTW. Here are my goals for the project:

Have all the functions used in MS Excel.

Combine with BIGINT or BIGNUM to make the ultimate lib.

Feel free to submit any function you want to this lib. And the authors of BIGINT and BIGNUM may want to help me with integration of their lib with these functions. Also, perhaps the authors of BIGINT and BIGNUM may want to combine to make the best big integer lib ever.
 Logged

Agamemnus
x/ \z

Posts: 3491

 « Reply #37 on: May 16, 2003, 05:27:09 PM »

It won't work, because we're using different coding methods.
 Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Meg
Ancient QBer

Posts: 483

 « Reply #38 on: May 16, 2003, 06:29:24 PM »

Code:
FUNCTION fct (n&)
IF n& = 0 THEN
c& = 1
ELSEIF n& MOD 1 THEN
c& = n& * fct(n& - 1)
ELSE
c& = 0
END IF

fct = c&
END FUNCTION

*peace

Meg.
 Logged
oracle
*/-\*

Posts: 3652

 « Reply #39 on: May 17, 2003, 01:05:01 AM »

Meg, your one doesn't work for me.

Agamemnus: Then don't help then.

I'm gonna ask about getting BIGINT or BIGNUM support, cos anything over 12! in QB is inaccurate without this.

Whoever wants to help, the first function is CEIL(x). This function should round up a number to the nearest integer. This should be pretty easy, or already a QB function if I haven't looked hard enough :wink:

The next function is CEILING(x, significance). This function rounds x up to the nearest multiple of significance. eg:
CEILING(1,4) returns 4
CEILING(5,4) returns 8
CEILING(81,27) returns 108

This function should return an error if the signs of each number are different.
 Logged

na_th_an
*/-\*

Posts: 8244

 « Reply #40 on: May 17, 2003, 09:13:43 AM »

Quote from: "Meg"
Code:
FUNCTION fct (n&)
IF n& = 0 THEN
c& = 1
ELSEIF n& MOD 1 THEN
c& = n& * fct(n& - 1)
ELSE
c& = 0
END IF

fct = c&
END FUNCTION

*peace

Meg.

The second IF branch will be never entered. n& MOD 1 is always false, as n& MOD 1 is always 0 (every number is divisible by 1, so the remaining will be always 0).
 Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Agamemnus
x/ \z

Posts: 3491

 « Reply #41 on: May 17, 2003, 10:48:56 AM »

I mean, bigint and bignum can't combine.
 Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
oracle
*/-\*

Posts: 3652

 « Reply #42 on: May 18, 2003, 05:28:23 PM »

Well maybe you two can get together and make a fast, accurate version of the lib. I've pm'ed Neo, but he is on holiday so we'll see.

Anyone working on the two functions above?
 Logged

Agamemnus
x/ \z

Posts: 3491

 « Reply #43 on: May 18, 2003, 11:38:44 PM »

Ceil is already a function. Instead of ceil, they renamed it cint, for "Conversion to Integer."
Why can't they just make it convert.to.integer(x), I don't understand.

I'm not sure what your Ceiling, does, though.
 Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
oracle
*/-\*

Posts: 3652

 « Reply #44 on: May 19, 2003, 01:07:15 AM »

CINT is not quite the same... It rounds numbers from 4.5 downwards down to 4, for example. I want a function that rounds, say 4.1, 4.00000001 and 4.7 up to 5 for example. It should work for negative numbers too, eg -4.5 rounds to -4.

CEILING rounds the value x up to the nearest common multiple of "significance". So when x=4 and sig=5 then x is rounded up to the nearest c.m which is 5, but when x=6 and sig=5 x is rounded up to 10, the next multiple of 5. If x=0 then the function should return 0.

Other examples:

CEILING(22, 5) returns 25
CEILING(-1, 5) returns function error (what ever error code that is)
CEILING(3,181) returns 181
 Logged

 Pages: 1 2 [3] 4