Help with a (double) sigmoid curve.

So, I’m trying to generate a double sigmoid curve using X values between 0 and 1, with the zero crossing/flat spot at 0.5.

Scouring the internet, the closest formula I could find was this double logistic curve (last formula in red on the page) but entering my data (and tweaking it in my amateur fashion) doesn’t generate anything close to the curve pictured.

I guess, worse case scenario, I could generate a single sigmoid over 0 to 0.5, another over 0.5 to 1, then use if logic to select between the two, but I’d prefer a more elegant solution, if possible.

So, any ideas on another formula, tweaks to the above formula, or ways to manipulate my dataset to generate this sort of curve over 0 to 1?

Thanks in advance.

Does this help?

An apparently this is the function for an asymmetric double sigmoid, but I certainly can’t vouch for it:

y = a[1+exp(-(x-c/2)/d]^(-1) * [1 - [1+exp(-(x-b-c/2)/e)]^(-1)]

for c, d, e, >0

according to www.roperld.com/science/doublesigmoid.pdf (obviously a pdf file)

What exactly are you trying to do?

Here’s a function that gives the general shape you’re looking for…

f(x) = 1/4 (tanh(8 (x - 3/4)) + 1) + 1/4 (tanh(8 (x - 1/4)) + 1)

Does that help?

OldGuy, I don’t think you transcribed that function correctly from the PDF. You’re missing the “b” in the denominator of the first factor.

The PDF also gives an alternate form using hyperbolic tangents similar to the one Lance Turbo gives:

y = 1/2 [ tanh((x-c[sub]1[/sub])/w[sub]1[/sub])) - tanh((x-c[sub]2[/sub])/w[sub]2[/sub]) ]

I’ll second the question. Any function which produces the qualitatively-correct shape will have a lot of adjustable parameters, and worse, there are many such functions to begin with. Knowing what you’re trying to model should at least point us in the direction of the right family of curves, and might also give insight as to which parameters are most significant.

Yeah, I hate typing math on this board and other similar ones without my handy MathType.

[QUOTE=Chronos]
I’ll second the question
[/QUOTE]

I always start in the wrong place.

Ultimately, I’m tying to generate a nonlinear (Win) Probability based on relative strengths.

Lets say, drag racing, you rate the strength of the cars on a 100 point scale, 0=Low/Bad, 100=High/Good.

A linear relationship would dictate that that a car rated a 70 matched up against a car rated a 50 would have 58.3% of the ‘resources’, and should win 58.3% of the time.

But my intuition tells me there is a ‘flat spot’ in the graph when the cars are evenly matched, where chance/luck takes over, and asymptotic tails to indicate that there is no such thing as a dead lock.

Ultimately, I would like to map a function to the data I have to be able to take the 58.3% of resources, and convert it to say 55.5% win probability. The shape of the double sigmoid curve I linked in my first post is suits my intuition, although that particular curve seems entirely too steep outside of the flat spot.

Apologies for the murky questions and answers; I’m obviously an amateur in this arena.

You could create a polynomial for this using Newton’s divided differences method easily enough, and it would have the added benefit that the derivatives are continuous and smooth at the transitions (this is not true of hyperbolic functions). I create functions like this when I am doing Fourier propagation or finite difference methods to window the functions and suppress ringing due to boundaries.

On edit (after seeing you post): I think the hyperbolic tangents would work fine for what your or doing, or you could look at cumulative distribution functions of various types (which is what you are doing anyway).

In that case, it sounds to me like the “resources” or “strengths” of the cars are already on an arbitrary scale, and that you could (probably) just as well rejigger the strength ratings so that the probability is in fact linear. That, or come up with some objective measures of the strengths of the cars (maximum acceleration, maximum speed, etc), and use those to produce a model.

I couldn’t get that function to ‘recover’ from the flat spot using the 0-100 model above to generate a ratio, then inputting that ratio into your formula in place of ‘X’.

But I’m in a rush and perhaps messed up the coding. I’ll tinker with the constants this evening when I get a chance, and I appreciate the help.

I see your point, but I think rejiggering the back end of this particular system is utterly beyond me; too many variables and too little information.

In my defense, I feel like the numbers used to generate the ratios are as good as objective information as I’m likely to get, and I think they’re accurate, in a perfect world.

Translating between the linear relationship and the besought double sigmoid curve is my attempt translate lab results into the real world, where any number of things might confound the outcome.

This is utterly beyond me, but that’s why I asked. Any chance you could point me to a resource for more reading?

And honestly, I’m just looking for nearly any function that would generate the approximate double sigmoid curve I linked that I could adapt to my data for a trial run.

So far, I’m unable to generate that curve with a ratio input.

I’m not sure what this means. Here’s a link that includes a plot of that function.

Gotcha, I accidentally tested it on a dataset that only went from 0 to 0.65.

If you go to you linked site and plot those parameters, you’ll see what I meant.

Hopefully I’ll be able to play with the constants and make that formula work, but I’d love to hear more discussion, or to be pointed to more (hopefully entry level) resources on how to generate curves of this general shape.

Thanks all.

For this kind of problem, the simplest and most direct approach is best. 1) Sketch the curve you want. 2) Choose just enough points on the curve to capture the essential behavior. 3) Interpolate between the points. Linear is usually enough, but you can get fancy and try some sort of spline.

When there’s no underlying model to support a specific sort of curve, there’s little to gain by trying to find some analytic function.

Right. I understand that, but I guess the main problem is I don’t necessarily know those points, just a general shape. In other words, I suspect a curve that flattens out near 0.5 will prove accurate, but should it do so from 0.45 to 0.55, or from 0.35 to 0.65, or somewhere else entirely? No idea.

I figured if I had an actual function to work from, I could mess with constants, bend the curve and do accuracy testing with the data I have, rather than have to come up with a complete custom system for each test.

The points you choose define the function. And in a very intuitive way. Rather than some complicated analytic function whose parameters interact in a perhaps inobvious way, you directly change the behavior of your function by moving the points around. Yes, it’ll be trial and error, but that’s going to be true no matter what.

And a piecemeal-defined function is a function. Unless you need some particular property (note that splines can be continuous after a couple derivatives) interpolated functions will do what you need.

Perhaps you could use the same type of algorithm that produces chess and go ratings? The scores are adjusted to match the win/loss records; it uses the logistic curve but you could substitute a different model.

Anyway, you need to let the computer find the most likely value of the parameters or even the shape of the curve itself using your model and the raw data, not tweak anything manually.

Here is another option that involves a few reasonable transformations to get you where you want.
Given initial Resources X and Y for the two players, use the following function to normalize the difference

D=(X-Y)/(X+Y) assuming the resources are bounded below by 0 this will be a value between -1 and 1.

We can then extend this to say that if either X or Y have all the resources than their advantage goes to infinity, by assigning A=tan(D*pi/2)

Finally based on this advantage curve you can use the logistic function to turn the advantage into a winning probability. P=1/(1+exp(-a*A))

where exp is the exponential function and a is a tuning parameter that you can use to decide how much of a sweet spot you want to give yourself. The smaller a is the flatter the center bit.

You can also add an additional parameter by adding an additional parameter b which modifies the tangent, with an additional adjustment to handle negative roots.

A=sign(D)abs(tan(Dpi/2))^b

The part of the task that I’m missing is: what data do you actually have? Is it a list of strengths and outcomes? And maybe you are taking all the cases where the strengths differ by a fixed amount and estimating a win percentage for the higher- or lower-ranked competitor? Are you assuming that a race between rank R=10 and R=20 has the same win/loss probability as a race between R=90 and R=100? Why is the idea of a flattening just a matter of your intuition? That is, can you just make a scatter plot of… something and see if there is or isn’t a flattening? Are the rankings determined from the outcomes of real races, or in some external way? Are you able to share the data set?

Sorry for the question bombardment when all you want is a function, but I suspect there are easier and better ways to accomplish your goal, but it’s hard to say without more details. It’s also not obvious to me why the function you ask for has anything to do with the data you would likely have for a drag racing scenario (which I know might just be a proxy for your real scenario).