Help me get the right function

tetch

New member
Joined
Apr 12, 2022
Messages
14
Hi,
I realy hope I'm writing it in the right place.
I'm a web developer and I am breaking my head over the mathematics for a feature I am trying to build.
Im calculating the ratio between two elements on the screen and I need to set the size of another element based on that ratio, as smaller the ratio the bigger the size.

I plugged in manually some numbers for the size for random ratios and I figured out the following:
- for the ratio of 0.13 the right size is 95
- ratio 0.19, size 62
- ratio 0.24, size 55
- ratio 0.33, size 45
- ratio 0.48, size 42
- ratio 0.55, size 32
- ratio 0.64, size 25
- ratio 0.79, size 20
- ratio 0.94, size 12

Basiclly I just need to figure out the right equation that will produce the size from a given ratio based on the examples above.

I really appreciate your help. ?
 
Hi. What are the largest and smallest ratios the software needs to handle?

:)

[imath]\;[/imath]
 
If you plot the size against the ratio, the graph is not very smooth.
1649813864826.png
The simplest "best fit" is probably a power function (\(\displaystyle R^2=0.955\)). Excel gives it as \(\displaystyle y = 16.092 x^{-0.892}\).
You could play around with that.
How accurate is your size 42? It seems to be a bit further away from the trend of the other data.

Otis's question (see post #2) is an important one because you might want to adjust the ends of the graph to suit.
(Eg using this model with ratio (x) = 0.01 will lead to a size of approx 979.)
 
Last edited:
I've plotted a graph for your points, and it does not look like any math function I am familiar with :unsure::
x1.png
 
Hi,
I realy hope I'm writing it in the right place.
I'm a web developer and I am breaking my head over the mathematics for a feature I am trying to build.
Im calculating the ratio between two elements on the screen and I need to set the size of another element based on that ratio, as smaller the ratio the bigger the size.

I plugged in manually some numbers for the size for random ratios and I figured out the following:
- for the ratio of 0.13 the right size is 95
- ratio 0.19, size 62
- ratio 0.24, size 55
- ratio 0.33, size 45
- ratio 0.48, size 42
- ratio 0.55, size 32
- ratio 0.64, size 25
- ratio 0.79, size 20
- ratio 0.94, size 12

Basiclly I just need to figure out the right equation that will produce the size from a given ratio based on the examples above.

I really appreciate your help. ?
Please explain how you calculated those ratios, and/or what determines them.
 
If you plot the size against the ratio, the graph is not very smooth.
View attachment 32103
The simplest "best fit" is probably a power function (\(\displaystyle R^2=0.955\)). Excel gives it as \(\displaystyle y = 16.092 x^{-0.892}\).
You could play around with that.
How accurate is your size 42? It seems to be a bit further away from the trend of the other data.

Otis's question (see post #2) is an important one because you might want to adjust the ends of the graph to suit.
(Eg using this model with ratio (x) = 0.01 will lead to a size of approx 979.)
Hi, Thank you for your response.
the number 42 might be not accurate, I pulgged the numbers and checked it by eye, so makes sense that i'll be off a bit.
the ratios will be between 0.1 and 0.99
 
Please explain how you calculated those ratios, and/or what determines them.
The ratios are determend by the user's screen size and layout and a picture he choose.
So for example if I have a very wide screen and I chose a wide but short picture the ratio will be closer to 1.

For my case the ratio is a given
 
If you plot the size against the ratio, the graph is not very smooth.
View attachment 32103
The simplest "best fit" is probably a power function (\(\displaystyle R^2=0.955\)). Excel gives it as \(\displaystyle y = 16.092 x^{-0.892}\).
You could play around with that.
How accurate is your size 42? It seems to be a bit further away from the trend of the other data.

Otis's question (see post #2) is an important one because you might want to adjust the ends of the graph to suit.
(Eg using this model with ratio (x) = 0.01 will lead to a size of approx 979.)
Thank you so much, this solved it for me perfectly
 
@Harry_the_cat
Do you mind explaining how you figured it out?
I plotted a scattergraph using Excel. And then fit a trend line. Excel did all the work. Knowing that it was some sort of inverse relationship, I chose a power function from the options as the most appropriate, but you could try all the options. Generally, the closer R^2 is to 1, the better the fit.
 
Top