Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Statistical Challenge
#31
OK then, I'll check later on neo's code, but now: Do the permutation and combination thingy.
Reply
#32
Permutation:

[Image: p1img2256.gif]

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

Combination:

[Image: c2img1243.gif]

Code:
FUNCTION combination(n&, k&)
   combination& = factorial(n&) / (factorial(n&-k&) * factorial(k&))
END FUNCTION
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#33
Good... na_th_an 2 : others 0

Now... statistical deviation. Two functions, one sample and one population.
Reply
#34
Heh... how about the binomial theorem while you're all at it... Big Grin
Reply
#35
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?
Reply
#36
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.
Reply
#37
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.
Reply
#38
It won't work, because we're using different coding methods.
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.
Reply
#39
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.
Reply
#40
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)