• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:59
CEST 17:59
KST 00:59
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL55Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event17Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
TRUSTED USDT RECOVERY TECHY FORCE CYBER RETRIEVAL Statistics for vetoed/disliked maps The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series Korean Starcraft League Week 77 Master Swan Open (Global Bronze-Master 2) [GSL 2025] Code S: Season 2 - Semi Finals & Finals
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL Replays question BW General Discussion Flash Announces Hiatus From ASL BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL20] Grand Finals - Sunday 20:00 CET Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Trading/Investing Thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 654 users

Modeling Function Help (math)

Blogs > kdog3683
Post a Reply
kdog3683
Profile Blog Joined January 2007
United States916 Posts
December 12 2007 03:54 GMT
#1
I've been given some random data.
X Y

0 440
6 450
12 480
18 570
24 680
30 800
36 980
42 1090
48 1520
54 1920
60 1670
66 1440
72 1380
78 1300
84 1150
90 1060
96 970
102 900
108 850
114 800
120 780
126 740
132 710
138 680
144 660

My task : To create a function which can model this data. Now my problem is, this function does not follow any one pattern. What I did instead, was break it up into 5 sections, and make a pseudo 'piece wise function.'

However,how would i go about creating one continuous function that is able to @ least closely model this data?


Here is a picture of the data :
http://img118.imageshack.us/my.php?image=68941387hc2.jpg

Thanks .[/img]

*
Multiply your efforts.
fanatacist
Profile Blog Joined August 2007
10319 Posts
December 12 2007 04:01 GMT
#2
Piece-wise is best for "sharp" graphs like this one, but I think for this situation an exponential or polynomial function is your best bet. Use your TI-81 calculator to create a ExpReg for data in L1 and L2 (you have to put the data in those).
Peace~
Folca
Profile Blog Joined October 2006
2235 Posts
December 12 2007 04:04 GMT
#3
On December 12 2007 13:01 fanatacist wrote:
Piece-wise is best for "sharp" graphs like this one, but I think for this situation an exponential or polynomial function is your best bet. Use your TI-81 calculator to create a ExpReg for data in L1 and L2 (you have to put the data in those).


yeah, pretty much what he said,
why would you come to teamliquid for math homework


TL IT UP PEOPLE TL IT UP SO HE NEVER ASKS AGAIN
Dea : one time when he was playing vs the comps he asked me "how do I make that flying unit that makes the other stuff invisible" and I reply "ur playing terran zomg"
pachi
Profile Joined October 2006
Melbourne5338 Posts
December 12 2007 04:27 GMT
#4
try a spline

cubic spline - http://img141.imageshack.us/img141/5152/splinezj9.jpg
you'll probably need a computer or something to work it out though.
Moderatorpachi fanclub http://goto.tl/6DI9 。◕‿◕。
fanatacist
Profile Blog Joined August 2007
10319 Posts
Last Edited: 2007-12-12 04:31:57
December 12 2007 04:31 GMT
#5
Rofl Zealot icons own your math!

(This shit just got zeal rushed)
Peace~
Polemarch
Profile Joined August 2005
Canada1564 Posts
December 12 2007 04:41 GMT
#6
It looks kind of like a Laplacian

c * e^(a |x - b| )
I BELIEVE IN CAPITAL LETTER PUNISHMENT!!!!!
Kennigit *
Profile Blog Joined October 2006
Canada19447 Posts
Last Edited: 2007-12-12 04:48:30
December 12 2007 04:48 GMT
#7
i think i have found the problem affecting your math homework.
[image loading]
LegendaryDreams
Profile Blog Joined November 2004
Canada1350 Posts
December 12 2007 05:01 GMT
#8
Plot the points in a graphing calculator and you will receive your function
call me moxie
azndsh
Profile Blog Joined August 2006
United States4447 Posts
December 12 2007 06:40 GMT
#9
On December 12 2007 14:01 LegendaryDreams wrote:
Plot the points in a graphing calculator and you will receive your function


GENIUS!

It's not really a Laplacian since it lacks symmetry... I'd go with the cubic spline.
Purind
Profile Blog Joined April 2004
Canada3562 Posts
December 12 2007 09:16 GMT
#10
You could make a 25th order polynomial (or would it be 24th?) that looks something like:
y = a*x^24 + b*x^23...... + c*x+d

Plug in your data sets and you'll get osmething like a 25 by 25 matrix with a, b, c...... as your variables. Ummm, it might be a pain in the ass to invert that manually, so use some sort of program like maple or mathematica to invert it for you
Trucy Wright is hot
Bill307
Profile Blog Joined October 2002
Canada9103 Posts
December 12 2007 10:25 GMT
#11
In general, you are looking for some method of Interpolation.

In this case, a cubic spline would be a much better choice than a 25th order polynomial. Firstly, a spline takes much less time to compute. Second, such a high-order polynomial will suffer from Runge's phenomenon, which basically means your resulting function will look absolutely horrendous towards the ends of your data.
micronesia
Profile Blog Joined July 2006
United States24667 Posts
Last Edited: 2007-12-12 16:39:59
December 12 2007 16:38 GMT
#12
You could use the solver in excel to minimize chi squared when fitting this to any function, and technically you would be accomplishing the goal you described. Is there any limit on how imprecise this can be? Otherwise a high order polynomial would be easy (3 minutes in excel, but no topic specific software help needed). If you decide to do it my way but don't know how, pm me. BTW, my method works for any type of function, not just polynomials (just minimize the sum of the difference of the square of the variations of the theoretical data points with the experimental data points, by toggling the parameters of the theoretical equation).

Edit: er I mean, minimize the sum of the square of the differences :-p
ModeratorThere are animal crackers for people and there are people crackers for animals.
ToT)SiLeNcE(
Profile Blog Joined February 2003
Germany590 Posts
Last Edited: 2007-12-12 18:03:07
December 12 2007 17:52 GMT
#13
First impression was that the data has been derived from a landau distribution :

http://en.wikipedia.org/wiki/Landau_distribution

Spline interpolation should work well, too.

edit : see http://rkb.web.cern.ch/rkb/PH14pp/node95.html for a closed form of the landau distribution.
kdog3683
Profile Blog Joined January 2007
United States916 Posts
December 13 2007 01:09 GMT
#14
I'm a bit confused between Spline interpolation and regular piece wise function.

To be more exact, what I did is :

f'x [0,54] + g'x [54,72] + h'x [ 72,104] + j'x [104,144] where the [a,b] is the x intervals.

I took the data given. I saw that from 0-54 it seemed like a quartic regression. So I do the regression and get a correlation of .993. I then imput this as f'x on the interval of [0-54]. Repeating the process with g'x, h'x etc.

What is the difference between this and a piecewise function?

Multiply your efforts.
Bill307
Profile Blog Joined October 2002
Canada9103 Posts
December 14 2007 05:31 GMT
#15
(The following is a response to one of kdog's PMs. I'm posting it here so that others can see it as well. In summary, I explain how to create a (natural) cubic spline and do a short 3-point example.)

Hi kdog,

I haven't done cubic splines in about 9 months, but I'll try my best to recall everything. Ignoring what Wikipedia says (because I don't understand it much myself ), the general idea is as follows: you want to have a cubic function between every two data points, and when two functions meet at a data point, their 1st AND 2nd derivatives are equal. (Earlier I forgot that the 2nd derivatives also have to be equal.)

Let's use your example:
x_0 = 0, y_0 = 5
x_1 = 1, y_1 = 6
x_2 = 2, y_2 = 10
x_3 = 3, y_3 = 20
x_4 = 4, y_4 = 8
x_5 = 5, y_5 = 7

So we will define 5 functions as follows:

f_i(x) = (A_i) + (B_i * x) + (C_i * x^2) + (D_i * x^3)

for i = 0, 1, 2, 3, 4

(I put each term in parentheses for better readability.)

Each function f_i is defined between points x_i and x_i+1.

Since each function has 4 unknown constants, and there are 5 functions, that means we have 20 unknown constants in total to determine. Therefore, we need 20 equations that constrain them.

First of all, because we want the combined function to pass through each data point, we have to satisfy the following equations:

f_i(x_i) = y_i (i.e. f_i has the correct value at its first endpoint)
f_i(x_i+1) = y_i+1 (i.e. f_i has the correct value at its second endpoint)

for i = 0, 1, 2, 3, 4

examples:
f_0(0) = 5
f_0(1) = 6
f_1(1) = 6
f_1(2) = 10
f_2(2) = 10
f_2(3) = 20
etc.

This gives us 10 equations. Second, we want the 1st and 2nd derivatives of the combined function to be continuous as well, i.e. we want the combined function to be smooth. We know that in each piece, the derivatives of a cubic function are continuous. So we just need to make sure the derivatives match-up at each data point, where two of the functions (say, f_i and f_i+1) intersect. That is, we must also satisfy the following equations:

f_i'(x_i+1) = f_i+1'(x_i+1)
f_i''(x_i+1) = f_i+1''(x_i+1)

for i = 0, 1, 2, 3

examples:
f_0'(1) = f_1'(1)
f_0''(1) = f_1''(1)
f_1'(2) = f_2'(2)
f_1''(2) = f_2''(2)
f_2'(3) = f_3'(3)
f_2''(3) = f_3''(3)
etc.

This gives us an additional 2*4 = 8 equations, for a total of 18. To create the last two equations, we apply extra boundary conditions at the first and last data points. There are a variety of options here, but a common one is called the "natural cubic spline", where the 2nd derivatives at the first and last data points are 0, i.e.:

f_0''(0) = 0
f_4''(5) = 0

This gives us a system of 20 equations and 20 unknown constants, allowing us to solve for the 20 unknown constants. If you were to do this by hand, you'd have to row-reduce a 20x20 matrix, so naturally I'm afraid I won't do that for your example . Realistically, you'd want to use a program that can do it automatically for you. For the data you gave us in your blog post, if you have 25 data points then you'd end up with (25-1)*4 = 96 equations and 96 unknown constants: easy for a computer, but death for a human .

I can quickly do a natural cubic spline between 3 data points, though, e.g.:

x_0 = 0, y_0 = 5
x_1 = 1, y_1 = 6
x_2 = 2, y_2 = 10

f_0 = A + Bx + Cx^2 + Dx^3
f_1 = E + Fx + Gx^2 + Hx^3

We end up with 8 equations:

f_0(0) = 5 : A = 5
f_0(1) = 6 : A + B + C + D = 6
f_1(1) = 6 : E + F + G + H = 6
f_1(2) = 10 : E + 2F + 4G + 8H = 10

f_0'(1) = f_1'(1) : B + 2C + 3D = F + 2G + 3H
or B + 2C + 3D - F - 2G - 3H = 0
f_0''(1) = f_1''(1) : 2C + 6D = 2G + 6H
or 2C + 6D - 2G - 6H = 0

(boundary conditions for a natural cubic spline
f_0''(0) = 0 : 2C = 0
f_1''(2) = 0 : 2G + 12H = 0

We can now create an 8x8 matrix to solve. You could solve it by hand by row-reducing the matrix, but I chose to use Mathematica instead .
[image loading]


So the end result is the following function:

f(x) =
{ 5 + (1/4 * x) + (3/4 * x^3), for x between 0 and 1
{ 13/2 - (17/4 * x) + (9/2 * x^2) - (3/4 * x^3), for x between 1 and 2

Graph plotted using MathGV:
[image loading]
kdog3683
Profile Blog Joined January 2007
United States916 Posts
Last Edited: 2007-12-16 08:42:26
December 16 2007 08:41 GMT
#16
Hi again.

In Mathematica, when creating a Matrix; is it possible to define each piece of it?

[image loading]
[/QUOTE]

In your example you used variables of (A, B, C, D) for fx 1. (E, F,G ,H) for fx2.
In a 96 x 96, I will run out of letters, so (a, b , c ,d) fx1, (a1, b1, c1, d1) fx2 and so forth until fx95.

Can I also , once I have defined each piece of it, import a data set into it?

Referring back to pic, can i do something like make a list to import into the matrix?

a1 = 2
a2 = 3
b1 = 3
b2= 4
Etc
With "else = 0" for a3, a4 .... a95

Importing all the data directly to the matrix would make the process much easier.

Thanks
Multiply your efforts.
Please log in or register to reply.
Live Events Refresh
PSISTORM Gaming Misc
15:55
FSL team league: ASP vs PTB
Freeedom0
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
trigger 333
Hui .277
SC2Nice 23
StarCraft: Brood War
Calm 9700
Horang2 2988
Bisu 2505
Jaedong 1919
Flash 1438
Mini 1162
Larva 1094
BeSt 798
firebathero 766
hero 473
[ Show more ]
actioN 400
Mind 191
Hyun 137
sSak 58
Mong 30
GoRush 19
zelot 14
Rock 13
Dota 2
LuMiX3
Heroes of the Storm
Khaldor507
Other Games
Gorgc4016
singsing3165
FrodaN1120
B2W.Neo1095
Lowko374
Mlord344
Fuzer 286
TKL 189
KnowMe120
Trikslyr62
Organizations
Other Games
EGCTV1218
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• HeavenSC 25
• Kozan
• AfreecaTV YouTube
• sooper7s
• intothetv
• Migwel
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• Michael_bg 6
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2956
• WagamamaTV616
• Ler59
League of Legends
• Nemesis7606
Upcoming Events
FEL
1m
CranKy Ducklings2
RSL Revival
18h 1m
Clem vs Classic
SHIN vs Cure
FEL
20h 1m
WardiTV European League
20h 1m
BSL: ProLeague
1d 2h
Dewalt vs Bonyth
Replay Cast
2 days
Sparkling Tuna Cup
2 days
WardiTV European League
3 days
The PondCast
3 days
Replay Cast
4 days
[ Show More ]
RSL Revival
4 days
Replay Cast
5 days
RSL Revival
5 days
FEL
6 days
RSL Revival
6 days
FEL
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.