Looking for Equation for pattern

MasterOfRa

New Member
Reaction score
10
[Solved]Looking for Equation for pattern

Found A site that does it.

http://zunzun.com/

I have a set of data, That I want to find the approximate equation to generate it, as in If I plug in X, I would get something reasonably close (+-20%) to y. The data is from total values of units spawned in waves for a game, and I am trying to make a system that generates waves randomly, So I need a method to get values reasonably close to what was already there. The values are from (1 - 41 x), you had this value for (y)

I am looking for a method to determine the equation, Not the equation itself, Being that I may have this problem in the future again, And being able to do it would help.
Code:
245
699
554
2000
1302
1340
2930
6075
10280
5200
3320
4960
9200
10955
5495
35915
20945
6265
35795
86195
22435
27185
36695
30135
51195
156245
126000
56045
105695
39415
120000
126000
72000
101000
110700
210000
240000
252000
492850
492850
594300
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Well, you're looking for the Affine function or the Quadratic function depending on wether or not the values are exponential.

Affine function: f(x) = a(x-h)+k (simple canonical form)
Quadratic function: f(x) = a(h-h)²+k (simple canonical form)

I suggest you look for both of these functions (on google) and give feedback.

Once you find which function you will use, you can put another (smaller) function at the end to generate random values.

e.g.

Code:
#include <fstream>
#include <stdlib.h>
#include <time.h>

const int a = 5;
const int h = 0;
const int k = 0;

double Affine(int x)
{
	return a * (x - h) + k;
}

double Quadratic(int x)
{
	return a * ((x - h) * (x - h)) + k;
}

int MOD(double x)
{
	return rand() % int((x / 2.0) * a);
}

int main(int argc, char** argv)
{
	using namespace std;
	ofstream ofs("C:\\Output.txt");

	srand(time(NULL));
	for (int i = 1; i <= 5; i++)
	{
		ofs << "x=" << i << " Affine=" << Affine(i) << " Quadratic=" << Quadratic(i) << endl;
	}
	for (int i = 1; i <= 5; i++)
	{
		ofs << "x=" << i << " Affine=" << Affine(i) - MOD(i) << " Quadratic=" << Quadratic(i) - MOD(i) << endl;
	}
	ofs.close();
	return 0;
}
In this case, the MOD function creates a random value and multiplies it by a (5) and that value is then substracted, to the Affine/Quadratic's function result. If you play well with the values (a, h, k) and MOD you can certainly get a such result.

Output:
x=1 Affine=5 Quadratic=5
x=2 Affine=10 Quadratic=20
x=3 Affine=15 Quadratic=45
x=4 Affine=20 Quadratic=80
x=5 Affine=25 Quadratic=125
x=1 Affine=4 Quadratic=4
x=2 Affine=6 Quadratic=18
x=3 Affine=14 Quadratic=40
x=4 Affine=14 Quadratic=74
x=5 Affine=18 Quadratic=115
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I'm taking a college course (Linear Algebra) that is going over something very similar. Putting all the data into a matrix, and knowing what sort of polynomial you are looking for (like ax^3 + bx^2 + cx + d, ax^2 + bx + c, ax + b, or simply a, etc), you can solve for the 'best fit' to the data, using something called the Least Squares solution. (Keep in mind that if it looks complicated, I don't understand much of the wiki's "solution", except for this image:
42463a6f4db009c27711b37cd7b29083.png
)

If you want, I could walk through the steps. I could also test its effectiveness using a form like ax^3 + bx^2 + cx + d, which has more terms, and see if it comes up with a=0,b=0,c=-41,d=1, as we expect/hope.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top