How to transform a dataset in the domain -1, 1 so that the data remains within constraints, but numbers closer to 0 are transformed more?

StackOverflow https://stackoverflow.com/questions/20624086

Pergunta

Every minute, I poll our database of customer service data for average overall experience in the past 24 hours. The result of the query is a float ranging from -1.0 to 1.0. I'm trying to create a dashboard that shows a circular gauge indicating overall positive or negative experience, but the problem I'm having is that, due to the nature of the data, the data always tends towards 0 rather than to the extremes.

What I'm hoping to do is create a function that "blows out" the numbers closer to 0 while still constraining the data to -1, 1.

I tried plotting something like this into WolframAlpha (x value is the input, y value is the output i'm looking for):

 1.00,  1.00
 0.40,  0.90
 0.05,  0.25
 0.00,  0.00
-0.05, -0.25
-0.40, -0.90
-1.00, -1.00

But my brain is tying itself into a knot trying to figure out what I'm doing with the resulting function. Any suggestions?

Foi útil?

Solução

Even though it doesn't exactly match your input (red dots in the image below), I'd suggest using the third root. In the plot below, this is the blue curve. You can compute this as pow(x, 1/3.) in most languages, although you might have to pay special care to negative values, i.e. taking the root of the absolute value and negating the result as required.

If you need a better fit to your data, you might also consider using some variant of atan. The purple curve in the plot is atan(9*x)/atan(9).

Function plots

  x    red    blue   purple
 1.00  1.000  1.000  1.000
 0.40  0.900  0.737  0.890
 0.05  0.250  0.368  0.290
 0.00  0.000  0.000  0.000
-0.05 -0.250 -0.368 -0.290
-0.40 -0.900 -0.737 -0.890
-1.00 -1.000 -1.000 -1.000

You can also use Wolfram Alpha to plot the third root or this atan function. That way, you can toy with these functions to adapt them to your needs.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top