math is over my head

mattyo's icon

I'm trying to put an s-curve into a buffer~ to use as a lookup table,
but I can't figure out the damn math. I gather the formula to use
would be: y= 1./ 1 + exp((b*x) -a)

b being a curve constant, & a shifting it. I was trying to peek into
a buffer using [expr 1. / 1. + exp(($f1*$f2) - $f3)] my curve
rockets up, but never levels out at the top.

Can someone who understands math tell me what I'm doing wrong?

Thank you o wise math people.

M

Peter McCulloch's icon

Couple of parentheses should clear things up:

try:

1./(1.+exp(($f1*$f2)-$f3)))

Right now you're adding 1/1 to exp(($f1...etc., so it will never level
out. (because the exp. is going to keep growing in value.) Once you
add the parentheses, you should see the expected asymptotic behavior.

Peter McCulloch

Peter Castine's icon

On around Mar 6, 2006, at 4:04, mattyo said something like:
> Can someone who understands math tell me what I'm doing wrong?

Peter McC. answered your top-level question. But if you're really
having a hard time with the math, you might want to take a look at
lp.scampf from Litter Power, which is there particularly for creating
S-shaped and other shaped-curves, doing all the hard math for you. Just
play with the number boxes in the help file until you get the shape you
want.

Here's a snapshot showing what it looks like:

I've removed the alpha channel to see if that helps the folks who have
been having problems viewing Max-generated TIFFs and colors are trimmed
to 4-bit resolution to minimize bandwidth. Forum readers will probably
have to download the Litter Starter Pack (URI below) to see it; sorry,
that's beyond my power to control.

Best, Peter C.

>
-------------- http://www.bek.no/~pcastine/Litter/ --------------
Peter Castine | ^
| Litter Power & Litter Bundle for Jitter
pcastine@gmx.net |
pcastine@bek.no | iCE: Sequencing, Recording, and Interface Building
4-15@kagi.com | for Max/MSP
| Extremely cool
| http://www.dspaudio.com
| http://www.dspaudio.com/software/software.html

roger.carruthers's icon

That works!
Cheers
Roger