B x(cm)
24.5 4.2
25.5 4.5
26.5 5.0
27.5 5.4
28.5 5.9
29.5 6.6
30.5 7.2
31.5 7.9
32.5 8.6
33.5 9.3
34.5 10.0
35.5 10.5
36.5 10.9
37.5 11.1
38.5 11.1
39.5 10.8
40.5 10.3
41.5 9.8
42.5 9.2
43.5 8.4
44.5 7.7
45.5 7.1
46.5 6.4
47.5 5.9
48.5 5.4
49.5 5.0
50.5 4.6
51.5 4.2
This is my data.
And y(x) = a/(b**2 + x**2)**3/2 is the equation to which I want to fit the above data but the problem I am facing is that value of b is coming negative. So I want to know how will I change the origin of the graph to get the right result
A few things:
are you sure the function is f(x) = a/(b**2 + x**2)**3/2 and not f(x) = a/(b**2 + x**2)**(3/2), mind the parentheses around (3/2).
gnuplot has integer division (a common pitfall for unexpected results), hence, (3/2) will be evaluated to 1 instead of the expected 1.5.
why not letting gnuplot find the offset? Just introduce a variable c which will account the x-offset and let it fit.
depending on your model, i.e. if the exponent is variable, you could also add a variable d for the exponent and let it find by the gnuplot fitting algorithm.
sometimes it's better if you help the fitting with good starting values.
Then you have to judge whether the fitted values are making sense or not, e.g. b<0 or d=0.794 ...
Code:
### fitting with finding x-offset automatically
reset session
$Data <<EOD
B x(cm)
24.5 4.2
25.5 4.5
26.5 5.0
27.5 5.4
28.5 5.9
29.5 6.6
30.5 7.2
31.5 7.9
32.5 8.6
33.5 9.3
34.5 10.0
35.5 10.5
36.5 10.9
37.5 11.1
38.5 11.1
39.5 10.8
40.5 10.3
41.5 9.8
42.5 9.2
43.5 8.4
44.5 7.7
45.5 7.1
46.5 6.4
47.5 5.9
48.5 5.4
49.5 5.0
50.5 4.6
51.5 4.2
EOD
f1(x) = a1/(b1**2 + (x-c1)**2)**(3/2)
f2(x) = a2/(b2**2 + (x-c2)**2)**(3./2)
f3(x) = a3/(b3**2 + (x-c3)**2)**d3
set fit quiet nolog
fit f1(x) $Data u 1:2 via a1,b1,c1
fit f2(x) $Data u 1:2 via a2,b2,c2
a3=11; b3=1; c3=40; d3=1.5 # sometimes it's better to help the fitting with some good starting values
fit f3(x) $Data u 1:2 via a3,b3,c3,d3
print sprintf("% 9s% 9s% 9s% 9s","a","b","c","d")
print sprintf("%9.3g %9.3g %9.3g",a1,b1,c1)
print sprintf("%9.3g %9.3g %9.3g",a2,b2,c2)
print sprintf("%9.3g %9.3g %9.3g %9.3g",a3,b3,c3,d3)
plot $Data u 1:2 w p pt 7,\
f1(x) w l lc "red",\
f2(x) w l lc "web-green", \
f3(x) w l lc "web-blue"
### end of code
Result:
a b c d
1.17e+03 10.3 37.9
2.73e+04 -13.6 37.9
343 8.66 37.9 0.794
I'm not sure, but I think the equation that you're trying to fit to may be inappropriate for the data. Perhaps you could rewrite your equation such that it's clearer.
Here's an example using the quadratic equation y(x) = a*x**2 + b*x + c to fit:
test.dat
24.5 4.2
25.5 4.5
26.5 5.0
27.5 5.4
28.5 5.9
29.5 6.6
30.5 7.2
31.5 7.9
32.5 8.6
33.5 9.3
34.5 10.0
35.5 10.5
36.5 10.9
37.5 11.1
38.5 11.1
39.5 10.8
40.5 10.3
41.5 9.8
42.5 9.2
43.5 8.4
44.5 7.7
45.5 7.1
46.5 6.4
47.5 5.9
48.5 5.4
49.5 5.0
50.5 4.6
51.5 4.2
quad_fit.gp
set term pos col
set out 'xy_fit.ps'
set title 'Quadratic Regression Example Scatterplot'
set ylabel 'Y'
set xlabel 'X'
set style line 1 ps 1.5 pt 7 lc 'red'
set style line 2 lw 1.5 lc 'blue'
set grid
f(x) = a*(x**2) + b*x + c
fit f(x) 'test.dat' using 1:2 via a, b, c
p 'test.dat' ls 1 t 'Datapoints', f(x) ls 2 t 'Quadratic Regression'
set out
Running gnuplot quad_fit.gp produces:
Related
I am trying to parse some data from Basketball-Reference, but so far I'm unable to do so. Here is my code for getting the raw html data
import requests
from bs4 import BeautifulSoup
url='https://www.basketball-reference.com/teams/DAL/2021/lineups/'
response=requests.get(url=url)
soup=BeautifulSoup(response.content,'html.parser')
>>soup.find(attrs={'id':"all_lineups_5-man_"}).find('table')
That last line gives an error, when it shouldn't. My guess is that it is happening because of the <!-- highlighted in yellow in the picture below. So my question is, how should I approach this?
You could loop through the comments, grab the tables, and then use pandas.
For example:
import pandas as pd
import requests
from bs4 import BeautifulSoup, Comment
from tabulate import tabulate
url = 'https://www.basketball-reference.com/teams/DAL/2021/lineups/'
response = requests.get(url)
soup = BeautifulSoup(
response.content, 'html.parser'
).find_all(text=lambda text: isinstance(text, Comment))
tables = [c for c in soup if "<div" in c]
frames = [pd.read_html(table, flavor="bs4") for table in tables]
print(tabulate(pd.concat(frames[-1])))
pd.concat(frames[-1]).to_csv("table_4.csv", index=False)
Output:
-- --- ------------------------------- ------ ----- ---- ---- ------ ---- ---- ------ ------ ----- ---- ------ ---- ----- ---- ----- ---- ----- ---- ---- ---- ---- ----
0 1 L. Dončić | T. Hardaway 435:01 1.9 1.8 -0.5 0.023 0.3 2.1 -0.012 0.025 -2 -3 0.012 -2.1 -3.9 -0.5 -3.9 -1.5 -3.2 0.8 -0.4 1.2 -1.1 -0.9
1 2 W. Cauley-Stein | L. Dončić 288:50 8.3 5.2 0.4 0.057 0.7 -1.3 0.032 0.06 -2.9 -3.8 -0.003 -0.6 1.2 5.3 1.2 2.5 5.5 0.6 -1.6 3 0.5 -0.8
2 3 L. Dončić | J. Richardson 266:22 -1.5 0 4.2 -0.023 -0.5 6.1 -0.071 -0.029 -1.1 -1 -0.01 -0.7 -3 -3.7 -3 -2.2 -5 -1.4 2.7 0.8 -4.4 -1.1
3 4 D. Finney-Smith | J. Richardson 252:38 -3.3 -0.5 5.1 -0.034 -0.4 5.8 -0.06 -0.04 -1.8 -2 -0.012 0.2 -1 -3.4 -1 -1.5 -3.5 0.3 0.2 0 -3.9 -1.7
4 5 T. Burke | L. Dončić 251:51 -2.2 3.2 1.1 0.03 -1.4 1.6 -0.052 0.021 -7.2 -9.5 -0.008 -3.8 -7 -1.4 -7 -2.8 -6.1 -3.6 0.3 1 -2.5 1.6
5 6 J. Brunson | T. Hardaway 246:37 -4.4 -2.9 -3.9 -0.012 -3.2 -3.8 -0.05 -0.027 4.5 3.7 0.06 -3.8 -8.1 -2.5 -8.1 -3.2 -7.2 -0.6 -1.2 0 -1.2 -1.6
6 7 T. Burke | J. Johnson 242:07 -2.5 2.3 -0.6 0.029 0.2 0.2 0.004 0.03 -7.2 -8.5 -0.042 -3.6 -7.1 -2.1 -7.1 -2.8 -6.2 -2.1 0 1.9 0 2.8
7 8 L. Dončić | D. Finney-Smith 236:07 -3.5 1.6 6.7 -0.019 -0.2 5.3 -0.055 -0.026 -6.4 -6.4 -0.064 -0.4 -2 -2.7 -2 -1.6 -3.6 0.2 0.9 -0.4 -3.1 -0.3
8 9 T. Hardaway | J. Richardson 230:38 -8.2 -0.7 7.3 -0.048 -0.8 8.8 -0.103 -0.059 -6 -5.8 -0.069 0.2 -2.7 -7.2 -2.7 -3.6 -8.3 -1.1 1 0.7 -5.3 0.1
9 10 L. Dončić | J. Johnson 229:11 -7.7 2.1 -1 0.028 -1.9 -1.8 -0.035 0.018 -10 -9.7 -0.11 -4.7 -9.1 -3 -9.1 -3.7 -7.8 -2.8 -0.9 0.8 -0.3 2.1
10 11 D. Finney-Smith | T. Hardaway 225:53 -1 3.8 10.2 -0.011 0 4.5 -0.04 -0.02 -8.6 -8.8 -0.077 0.9 -0.6 -5.2 -0.6 -2.2 -5.1 2.3 0.7 -0.9 -5.1 -0.1
11 12 W. Cauley-Stein | T. Hardaway 215:03 12.3 6 -0.9 0.071 1.8 -4.1 0.085 0.082 -1.4 -3.8 0.056 -1.9 -1.2 4.4 -1.2 1.6 3.4 3.9 -1.3 2.7 -0.4 0.1
12 13 T. Hardaway | J. Johnson 214:53 -2.7 0.3 -4.9 0.029 -0.1 -6.5 0.06 0.033 -3.1 -3.6 -0.017 -4.9 -9.3 -2 -9.3 -3.5 -7.8 -2 -0.2 1.2 1 2.1
13 14 J. Brunson | J. Johnson 190:02 -11.5 -1.6 -3.6 0.001 -4.7 -8.1 -0.052 -0.024 -3.7 -2.3 -0.081 -4.7 -9.6 -3.4 -9.6 -4 -8.7 -2.3 -1.9 0.5 0.5 1.8
14 15 T. Hardaway | K. Porziņģis 188:30 -12.7 -6.6 -3.2 -0.055 -1.1 4.8 -0.074 -0.059 1.7 -2.9 0.192 -3.2 -7.3 -5 -7.3 -4.5 -9 -0.6 -3.2 0.1 0.8 -1.2
15 16 L. Dončić | K. Porziņģis 181:14 -8.8 -2.5 -2.1 -0.017 -2.6 3.3 -0.1 -0.03 -1.1 -6.7 0.19 -2.5 -4.9 -1.7 -4.9 -2.6 -5.4 0.2 -4.1 1.5 1.8 0
16 17 T. Hardaway | D. Powell 178:57 -3.2 -0.7 2.1 -0.019 2 3.1 0.025 -0.009 -3.9 -3 -0.071 -2.4 -6.7 -6.1 -6.7 -4.3 -9.7 -0.7 1.2 0.3 -1.5 -0.1
17 18 T. Burke | T. Hardaway 177:36 -2.2 -2.4 -3.7 -0.008 2 2.8 0.027 0.006 0.5 -0.9 0.047 -3.3 -6 -1.8 -6 -3 -6.2 -6.2 2 1.3 0.7 0.1
18 19 J. Brunson | L. Dončić 165:52 -3.6 -0.8 -7.2 0.029 -4.4 -5.7 -0.077 0.008 2.5 3.1 0 -6.2 -11.6 -0.7 -11.6 -3.5 -7.8 0.2 -1.4 1.8 1.1 -1.6
19 20 L. Dončić | D. Powell 162:30 -5 0.3 2.3 -0.009 1 3 -0.002 -0.005 -6.6 -4.3 -0.119 -4.3 -11.1 -7.3 -11.1 -5.8 -13.2 0.7 2.3 0.7 -4.3 0.2
20 nan Team Average 965:54 -2.1 0.4 0.6 0.002 -0.7 0.8 -0.025 -0.002 -2.2 -2.3 -0.021 -2.1 -4.7 -2.3 -4.7 -2.2 -4.9 -0.4 -0.6 0.5 -1.8 -0.3
-- --- ------------------------------- ------ ----- ---- ---- ------ ---- ---- ------ ------ ----- ---- ------ ---- ----- ---- ----- ---- ----- ---- ---- ---- ---- ----
Sample output for a .csv file:
This code is used to display a logo from a reactjs project, but the text of it does not make any sense. What are all the numbers?
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
See docs about path in SVG
A path is described using the concept of a current point. In an
analogy with drawing on paper, the current point can be thought of as
the location of the pen. The position of the pen can be changed, and
the outline of a shape (open or closed) can be traced by dragging the
pen in either straight lines or curves.
Paths represent the geometry of the outline of an object, defined in
terms of moveto (set a new current point), lineto (draw a straight
line), curveto (draw a curve using a cubic Bézier), arc (elliptical or
circular arc) and closepath (close the current shape by connecting to
the last moveto) commands. Compound paths (i.e., a path with multiple
subpaths) are possible to allow effects such as "donut holes" in
objects.
That's an svg file. Those numbers are setting the path of the drawing (as the direction of a pencil in paper)
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
If you render it , you'll be able to see the icon:
render: function() {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
(...) //your svg contents here
</svg>
);
}
Reading this answer, you could also render it like:
import { ReactComponent as logosvg} from './logo.svg';
const App = () => (
<div>
<logosvg/>
</div>
);
Which also would be a lot cleaner, since you don't need to include the entire contents of the svg file in your code.
Regardless of how you render it, the result is this:
So all those numbers inside the path are the ones defining the symbol (guiding the pencil).
Besides the numbers inside <path>, the other elements are also setting its properties. For example, <circle cx="420.9" cy="296.5" r="45.7"/> is the one responsible for drawing the inner circle.
Take that part off and you lose the nucleum (so the logo is not as cool as before):
I am trying to use the summation expression in Gnuplot but it is not working properly. I have the following data structure with many number of rows:
t x1 y1 z1 x2 y2 z2 x3 y3 z3 ... x98 y98 z98
I would like to plot the following equation:
u = (sqrt(sum(x)**2 + sum(y)**2 + sum(z)**2))/98
98 is the number of points (x,y,z).
What I have until now is how to plot the average of columns x1, x2, x3.. as following:
plot 'data file' u 1:((sum[i=0:ColCount-1] column(i*ColStep+ColStart))/ColCount) w lines ls 4 notitle
Where ColCount = 98, ColStep = 3 and ColStart=2.
But I have been trying to plot the equation, but it is not working. I would really appreciate any help.
What the following script does:
It takes the square root of the sum of (x1+x2+x3)**2 and (y1+y2+y3)**2 and (z1+z2+z3)**2. This you can adapt to your column numbers.
But I'm still not sure whether this is what you want. Please clarify.
Code:
### summing up columns
reset session
$Data <<EOD
#t x1 y1 z1 x2 y2 z2 x3 y3 z3
1 1.11 1.21 1.31 2.11 2.21 2.31 3.11 3.21 3.31
2 1.12 1.22 1.32 2.12 2.22 2.32 3.12 3.22 3.32
3 1.13 1.23 1.33 2.13 2.23 2.33 3.13 3.23 3.33
4 1.14 1.24 1.34 2.14 2.24 2.34 3.14 3.24 3.34
5 1.15 1.25 1.35 2.15 2.25 2.35 3.15 3.25 3.35
6 1.16 1.26 1.36 2.16 2.26 2.36 3.16 3.26 3.36
7 1.17 1.27 1.37 2.17 2.27 2.37 3.17 3.27 3.37
8 1.18 1.28 1.38 2.18 2.28 2.38 3.18 3.28 3.38
9 1.19 1.29 1.39 2.19 2.29 2.39 3.19 3.29 3.39
EOD
ColStep = 3
ColCount = 3
mySum(ColStart) = sum[i=0:ColCount-1] column(i*ColStep+ColStart)
plot $Data u 1:(sqrt(mySum(2)**2 + mySum(3)**2 + mySum(4)**2)) w lp pt 7 notitle
### end of code
Result:
I am trying to fit a sinc function with gnuplot but it fails with the message:
'Undefined value during function evaluation'.
First my data:
27 9.3
27.2 9.3
27.8 9.3
29 9.4
32 9.5
34 9.6
34.2 9.7
34.4 9.7
34.6 9.8
34.8 10.1
35 10.9
35.2 12.9
35.4 16.1
35.6 21.1
35.8 26.5
36 31.8
36.2 34.7
36.4 36.6
36.6 36.3
36.8 32.3
37 26.4
37.2 20.6
37.4 15.4
37.6 11.6
37.8 9.9
38 9.6
38.5 10
39 9.5
39.5 9.5
40 9.6
What I am trying to do in Gnuplot:
sinc(x)=sin(pi*x)/pi/x
f(x)=a*(sinc((b*(x-c))))**2+d
fit f(x) '4_temp.txt' via a,b,c,d
I set a,b,c,d close to the values that are needed (see picture) but it wont fit.
Somebody can help?
Thanks in advance.
I can reproduce your error message. You are trying to fit a sin(x)/x function. For x=0 you will get 0/0, although, gnuplot has no problems to plot sin(x)/x, apparently, fitting has a problem with this.
Only if you add a little offset, e.g. 1e-9, it seems to work and it will find some reasonable parameters.
As #Ethan says, you need to choose some starting values which should not be too far away from the final values.
You will get the fitted values:
Final set of parameters Asymptotic Standard Error
======================= ==========================
a = 27.5271 +/- 0.2822 (1.025%)
b = 0.608263 +/- 0.006576 (1.081%)
c = 36.3954 +/- 0.00657 (0.01805%)
d = 9.21346 +/- 0.127 (1.379%)
Code:
### fitting type of sin(x)/x function
reset session
$Data <<EOD
27 9.3
27.2 9.3
27.8 9.3
29 9.4
32 9.5
34 9.6
34.2 9.7
34.4 9.7
34.6 9.8
34.8 10.1
35 10.9
35.2 12.9
35.4 16.1
35.6 21.1
35.8 26.5
36 31.8
36.2 34.7
36.4 36.6
36.6 36.3
36.8 32.3
37 26.4
37.2 20.6
37.4 15.4
37.6 11.6
37.8 9.9
38 9.6
38.5 10
39 9.5
39.5 9.5
40 9.6
EOD
a=25
b=1
c=36
d=10
sinc(x)=sin(pi*x)/pi/(x)
f(x)=a*(sinc((b*(x-c+1e-9))))**2+d
set fit nolog
fit f(x) $Data via a,b,c,d
plot $Data u 1:2 w p pt 7, f(x) w l lc rgb "red"
### end of code
Result:
How do you resize or set the height and width of a Font Awesome 5 SVG? For example why
<path d="m25 43.5000536c0-1.354163.4947901-2.5260352 1.4843715-3.5156166.9895813-.9895813 2.1614535-1.4843714 3.5156166-1.4843714h7.4999821v24.9999404h-7.4999821c-1.3541631 0-2.5260353-.4947901-3.5156166-1.4843715-.9895814-.9895814-1.4843715-2.1614536-1.4843715-3.5156166zm44.9998927-4.999988c1.3541631 0 2.5260353.4947901 3.5156166 1.4843714.9895814.9895814 1.4843715 2.1614536 1.4843715 3.5156166v14.9999643c0 1.354163-.4947901 2.5260352-1.4843715 3.5156166-.9895813.9895814-2.1614535 1.4843715-3.5156166 1.4843715h-7.4999821v-24.9999404zm-29.9999285 24.9999404v-24.9999404h19.9999524v24.9999404zm13.7499673-18.1249568c-.5208325 0-.963539.1822908-1.3281219.5468737-.3645828.3645828-.5468737.8072893-.5468737 1.3281218s.1822909.963539.5468737 1.3281218c.3645829.3645829.8072894.5468737 1.3281219.5468737.5208324 0 .9635389-.1822908 1.3281218-.5468737.3645828-.3645828.5468737-.8072893.5468737-1.3281218s-.1822909-.963539-.5468737-1.3281218c-.3645829-.3645829-.8072894-.5468737-1.3281218-.5468737zm0 7.4999821c-.5208325 0-.963539.1822908-1.3281219.5468737-.3645828.3645829-.5468737.8072893-.5468737 1.3281218s.1822909.963539.5468737 1.3281219c.3645829.3645828.8072894.5468737 1.3281219.5468737.5208324 0 .9635389-.1822909 1.3281218-.5468737.3645828-.3645829.5468737-.8072894.5468737-1.3281219s-.1822909-.9635389-.5468737-1.3281218c-.3645829-.3645829-.8072894-.5468737-1.3281218-.5468737zm-7.4999822-7.4999821c-.5208325 0-.9635389.1822908-1.3281218.5468737-.3645829.3645828-.5468737.8072893-.5468737 1.3281218s.1822908.963539.5468737 1.3281218c.3645829.3645829.8072893.5468737 1.3281218.5468737s.963539-.1822908 1.3281219-.5468737c.3645828-.3645828.5468737-.8072893.5468737-1.3281218s-.1822909-.963539-.5468737-1.3281218c-.3645829-.3645829-.8072894-.5468737-1.3281219-.5468737zm0 7.4999821c-.5208325 0-.9635389.1822908-1.3281218.5468737s-.5468737.8072893-.5468737 1.3281218.1822908.963539.5468737 1.3281219c.3645829.3645828.8072893.5468737 1.3281218.5468737s.963539-.1822909 1.3281219-.5468737c.3645828-.3645829.5468737-.8072894.5468737-1.3281219s-.1822909-.9635389-.5468737-1.3281218c-.3645829-.3645829-.8072894-.5468737-1.3281219-.5468737z" opacity=".25" />
is smaller than,
<path d="M103.3 344.3c-6.5-14.2-6.9-18.3 7.4-23.1 25.6-8 8 9.2 43.2 49.2h.3v-93.9c1.2-50.2 44-92.2 97.7-92.2 53.9 0 97.7 43.5 97.7 96.8 0 63.4-60.8 113.2-128.5 93.3-10.5-4.2-2.1-31.7 8.5-28.6 53 0 89.4-10.1 89.4-64.4 0-61-77.1-89.6-116.9-44.6-23.5 26.4-17.6 42.1-17.6 157.6 50.7 31 118.3 22 160.4-20.1 24.8-24.8 38.5-58 38.5-93 0-35.2-13.8-68.2-38.8-93.3-24.8-24.8-57.8-38.5-93.3-38.5s-68.8 13.8-93.5 38.5c-.3.3-16 16.5-21.2 23.9l-.5.6c-3.3 4.7-6.3 9.1-20.1 6.1-6.9-1.7-14.3-5.8-14.3-11.8V20c0-5 3.9-10.5 10.5-10.5h241.3c8.3 0 8.3 11.6 8.3 15.1 0 3.9 0 15.1-8.3 15.1H130.3v132.9h.3c104.2-109.8 282.8-36 282.8 108.9 0 178.1-244.8 220.3-310.1 62.8zm63.3-260.8c-.5 4.2 4.6 24.5 14.6 20.6C306 56.6 384 144.5 390.6 144.5c4.8 0 22.8-15.3 14.3-22.8-93.2-89-234.5-57-238.3-38.2zM393 414.7C283 524.6 94 475.5 61 310.5c0-12.2-30.4-7.4-28.9 3.3 24 173.4 246 256.9 381.6 121.3 6.9-7.8-12.6-28.4-20.7-20.4zM213.6 306.6c0 4 4.3 7.3 5.5 8.5 3 3 6.1 4.4 8.5 4.4 3.8 0 2.6.2 22.3-19.5 19.6 19.3 19.1 19.5 22.3 19.5 5.4 0 18.5-10.4 10.7-18.2L265.6 284l18.2-18.2c6.3-6.8-10.1-21.8-16.2-15.7L249.7 268c-18.6-18.8-18.4-19.5-21.5-19.5-5 0-18 11.7-12.4 17.3L234 284c-18.1 17.9-20.4 19.2-20.4 22.6z"></path>
Thanks.