PID controller thread off topic fork

Things that are not directly connected with Factorio.
raidho36
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Wed Jun 01, 2016 2:08 pm
Contact:

PID controller thread off topic fork

Post by raidho36 »

mmmPI wrote: ↑Wed Oct 11, 2023 1:56 pm And another one that's troubling me from a math stand point, is that without clock the accumulator increases really fast in real time to the point where overflow is a risk for high target value ; as the static error is added 60 times per second when the system is stable. That translate to an allowance for maximum static error of around 10K for overflow every hour ((2^31) - (60^3) x = 1) Which would cause a system-breaking sign inversion i fear. Which makes me say that the small version is more suited to small quantity not millions of steam in buffer. But also for small quantities where some static error is allowed so which may be rare in vanilla factorio.
Inputs in 0-100 range (there's an input divider if you use e.g. steam tanks) running for an hour accumulate to a maximum of 21.6 million. That allows for I value up to 100, which is pretty big. Overflows might become a problem if full throttle isn't enough power and idle is too much, so it never settles and keeps increasing. Real systems use upper and lower accumulator bounds for this.
prices of stocks are updated randomly each tick, with a range (40-60%) chance of increase/decrease. This being influenced by another number the "trend" that goes up and down in cycle of unknown period but can also be randomly switch each tick with a lower probability.
Real stock markets are completely random on any time scale as a law of nature. It's literally always true for all assets on every market for any time period. Because stock price has to start at 0 and end at 0 and there is exactly 1 point where it was the highest, it'll rougly increase from 0 to that point and then rougly decrease back to 0. So that is technically an exception to that rule. Except you have no way of knowing when the highest point would be/was, and how long it is until it hits 0 since then, so this doesn't helps you make a judgement, and doesn't makes for a real exception. Also, fun fact, stock market trading is a zero sum game - in order for someone to profit, someone else has to lose equal amount of money.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: PID controller

Post by mmmPI »

raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Inputs in 0-100 range (there's an input divider if you use e.g. steam tanks) running for an hour accumulate to a maximum of 21.6 million. That allows for I value up to 100, which is pretty big. Overflows might become a problem if full throttle isn't enough power and idle is too much, so it never settles and keeps increasing. Real systems use upper and lower accumulator bounds for this.
Changing input range seem obvious now to prevent overflow since number of tanks is known it can be used to make %.

The case when it never settles if it keeps increasing and overflow, i'm not sure i'm picturing this correctly i think it will turn negative, so it stop adding fuel until quite some time, and start over slowly but increasing and redo in cycle i suppose ? ( depending on "I" value ). Not the intended kind of regulation but it's still one on a system that was not going to work anyway.

Whereas it would have been more problematic if an history of small positive static error amounting to colossal surplus due to waiting forever would suddenly turn into a massive debt and trigger the massive response ( refuel ). Which is what i saw as risk previously.

I am still tempted to mess with the integral part and try to make it forget the old history overtime so that it stays responsive without overshooting initially. Maybe something like removing 1% of the value in the integral-accumulator every 10 ticks or something similar, so that it only grows only up to so high or so low and tend to forget a prolonged period of error without the need to compensate by a long period of the opposite error.

I wouldn't know nor want to math those out to make sure it is making sense first, i think it's more fun to try and plot the value in a display in factorio and do some experiment with the combinators instead of the math formula this feels like a nice toy :)

Real stock markets are completely random on any time scale as a law of nature. It's literally always true for all assets on every market for any time period. Because stock price has to start at 0 and end at 0 and there is exactly 1 point where it was the highest, it'll rougly increase from 0 to that point and then rougly decrease back to 0. So that is technically an exception to that rule. Except you have no way of knowing when the highest point would be/was, and how long it is until it hits 0 since then, so this doesn't helps you make a judgement, and doesn't makes for a real exception. Also, fun fact, stock market trading is a zero sum game - in order for someone to profit, someone else has to lose equal amount of money.
Yes and no , in factorio the quantity of steam in tanks would be following the same rules, going from 0 to 0 and completly random in the middle from the PID point of view. Yet it would be able to modulate the refueling according to solar cycle if you have some solar pannel, and so despite the occasionnal spike in consumption caused by waves of biters eventually due to the feedback loop mechanism. ( you could eventually somehow tell it's night time with some degree of confidence when the pid is telling you to increase refuel periodically by the same amount if you have say enough solar pannel to cover 50% of your need at daytime and big biter waves/noise is only 10% surplus those ratios seems like it would yield a very visible sin-looking like consumption of fuel).

This is the underlying assumption of the existence of "trend" and "trend reversal", which is not the same as random walk, both are needed in the case of the betting algo ( or the linked model earlier) .In real life they only know they had wrong assumptions when model fail, which is a good opportunity to make a new model which will fail eventually unless we stop evolving i suppose :roll: I'd rather play video games :)

If you take 1 dice, and roll, add that number, then roll , subtract that number and repeat. Then there is no trend, model wouldn't work as one assumption is not respected although although the random walk is.

Now suppose some rules that will yield a trend-like behavior : if you reach 12 you are allowed to add 1 point to each following result , and -12 you remove 1 point in each following result. That's 1 in the trend counter. Trend counter reset at 10.

Suddenly you have a model where by measuring you can detect the existence of trend despite the randomness of each dice roll. If you tailor your model to a specific game / fixed settings you can achieve surprinsingly good results vs the seemingly chaotic nature of the measures.

Then add many stocks. And make it so that player just try to win virtual money that is created for them in a virtual world as a reward for their algo working and it's positive game sum ! i mean players may find they wasted their time for virtual money, but the fun is really into making the algo work, or the PID, maybe i won't manage to use it properly in a factory, but it's a good time playing with it and experimenting :)
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: PID controller

Post by Qon »

raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Real stock markets are completely random on any time scale as a law of nature. It's literally always true for all assets on every market for any time period. Because stock price has to start at 0 and end at 0 and there is exactly 1 point where it was the highest, it'll rougly increase from 0 to that point and then rougly decrease back to 0. So that is technically an exception to that rule. Except you have no way of knowing when the highest point would be/was, and how long it is until it hits 0 since then, so this doesn't helps you make a judgement, and doesn't makes for a real exception. Also, fun fact, stock market trading is a zero sum game - in order for someone to profit, someone else has to lose equal amount of money.
All of this is wrong.

raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Real stock markets are completely random
Stock prices are what people choose to buy and sell for. That's not random, that's cause and effect. It can be modeled as a random process to abstract away the details we don't know when dealing with a lack of information on the people involved and the events related to the company, even more so with more than a handful of people.
Saying it is completely random leaves no space for any explanation of causal events in the world.
Yes a dice is random. But it isn't "completely" random, there's a physical dice following the physical laws. Completely random means no knowledge about the world state and dice before the throw or any laws of physics have any impact at all on what the outcome will be.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm on any time scale
I would say time scale matters, and maybe not even consistent relation to the timescale length.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm as a law of nature.
No! :roll:
The heat death (or other) of the universe and end of time ending value of companies as the natural law that guarantees the end of the stock value seems a bit far fetched. The natural laws are not about companies, companies are not physics, chemistry or biology.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm It's literally always true for all assets on every market for any time period.
Are you just doubling down on the absolutism to exaggerate beyond reason?
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Because stock price has to start at 0
No stock for a public company at an open exchange starts at 0. Since you like absolute statements so much: It has never happened and never will.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm and end at 0
I wouldn't be surprised if you are the most wrong anyone has ever been on this as well. If a stock reaches 0 it could be because it reaches low values faster than stock merges or de-listing from the market can happen, and that the 1 cent minimum price increment can't account for the sub-cent values for an entire company valued more than 0. Maybe it's something that happens, that companies reach 0 on the market.
https://marketrealist.com/p/can-stocks-go-negative/ wrote:In reality, stock exchanges delist shares before they fall to zero. As a result, many companies with low stock prices go for a reverse stock split. In a reverse stock split, the company lowers its outstanding shares by consolidating them.
I can't even find a single example of any stock reaching 0. And those writing the article didn't either it seems:
https://marketrealist.com/p/can-stocks-go-negative/ wrote:What happens when a stock price falls to zero?

If a stock price falls to zero, you lose all of your investment in the company. However, stock prices don't usually fall to zero even if the company goes bankrupt. The company still has some value. One example of a stock that has fallen to almost zero is Helios and Matheson Analytics. The parent company of MoviePass trades at $0.00050 in OTC markets. That’s as near to zero as you can get.
You will basically lose your investment before it reaches 0. And the stock will have positive value even if the company is valued in the negative.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm and there is exactly 1 point where it was the highest,
Since you talk in absolutes I'm going to nitpick to the extreme, to prove that you are wrong multiple times per sentence in the whole paragraph. Stocks can reach their top value multiple times. Finite price precision makes this even more likely. Has probably happened, though I'm not going to bother finding any examples.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm it'll rougly increase from 0 to that point and then rougly decrease back to 0.
Since stocks are listed initially above 0 you would be more accurate to say that value is roughly decreasing from the start until the end. If you are going to be an exaggerating reductionist. This is obviously not a helpful model to use exclusively, "no one" (maybe you do?) buys a stock for the purpose of waiting until it becomes worthless so that you can get rid of money.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm So that is technically an exception to that rule.
You disagreeing with what you've said before on the topic is probably the only way you can be correct on the topic.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Except you have no way of knowing when the highest point would be/was, and how long it is until it hits 0 since then, so this doesn't helps you make a judgement, and doesn't makes for a real exception.
Yes if you know nothing at all and think stock prices are completely random then it makes sense that you can't predict the future with any accuracy at all.
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Also, fun fact, stock market trading is a zero sum game - in order for someone to profit, someone else has to lose equal amount of money.
Stock market prices are not in a vacuum though. You can get other value than just selling the stock, like dividends, and the effects the company has on the external world and the influence your share has over it. Dividend money come from selling product to customers. And yes customers lose money when buying things, but they value the product more. So everyone can profit.
PID
I don't trust your judgement that PID controllers are a useful tool for stock market investment or modeling.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: PID controller

Post by mmmPI »

Qon wrote: ↑Tue Oct 17, 2023 5:38 pm
PID
I don't trust your judgement that PID controllers are a useful tool for stock market investment or modeling.
Well then you agree with raidho36, i'm the one who said the PID controller math are similar to what one can use to analyze stock market in video game that happen to represent it with certain form of randomness that makes using proportionnal integral derivative math usefull to detect trend, such as one you could detect with a PID in factorio that would tell you to use more fuel at night if you have split nuclear-solar power.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: PID controller

Post by Qon »

mmmPI wrote: ↑Tue Oct 17, 2023 5:44 pm
Qon wrote: ↑Tue Oct 17, 2023 5:38 pm
PID
I don't trust your judgement that PID controllers are a useful tool for stock market investment or modeling.
Well then you agree with raidho36, i'm the one who said the PID controller math are similar to what one can use to analyze stock market in video game that happen to represent it with certain form of randomness that makes using proportionnal integral derivative math usefull to detect trend, such as one you could detect with a PID in factorio that would tell you to use more fuel at night if you have split nuclear-solar power.
Oh, if you said it and not raidho36 then I'm sure it does work ;)
But actually, I'm not convinced it is reliable for any real company. A random process to simulate price changes of a stock is maybe simple enough to be modeled and predicted itself by a PID controller, so that could work.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
raidho36
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Wed Jun 01, 2016 2:08 pm
Contact:

Re: PID controller

Post by raidho36 »

Qon wrote: ↑Tue Oct 17, 2023 5:38 pm
That's a lot of pedantry for making no point at all; If I were to spell out every asterisk this would be an 800 page book. Better yet, you say I make wrong statements with no basis, without backing any of that up yourself. Well I'll have you know I analyzed about a decade worth of stock market data. I made up all sorts of ways of applying autoregressions and it all came out empty. Most notably the table of odds of price going up or down (binary) depending on the previous pattern - the entire grid came out as 50/50. And so did SGD data-fitted technical analysis indicators, which were allowed to be composed of all sorts of equations, not just the known ones, for completeness sake: humans can't think of everything but a machine combing through possible permutations - can. Maybe a DLNN can figure out something with better accuracy than 50% (i.e. zero ability to make a prediction) but how it's able to do that is firmly outside the realm of human comprehension.

The way PID controller can even be used here is to maintain a stock's price at a steady level by buying and selling arbitrary amounts of it. PID controllers don't model their respective system, they compensate for external forces acting upon that system.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: PID controller

Post by mmmPI »

I used the PID for a mall, it try to reach target value while reading a portion of full loop to maintain desired item available for military and combinator mall.

To avoid too many items clogging the loop materials are removed and reinserted with priority over new material and there is a little room for a excess to stockpile all done using splitters.

Pid is reading some belt before the refilling area and some belt after the refilling area, and try to keep the (depleted+refilled) belt to target value by enabling some feeder belt.

Fun to use, not space efficient in my case, not too hard to configure, works fine so far.
pidformall.png
pidformall.png (1.42 MiB) Viewed 6162 times
Qon wrote: ↑Tue Oct 17, 2023 5:38 pm Stock prices are what people choose to buy and sell for. That's not random, that's cause and effect.
Yes and no, the coin flip is cause and effect too, yet it's considered random. The possibility to know all the causes and predict the effect can be beyond realm of our perception and as such we can choose to use other model to gain useful knowledge.

What people choose to buy and sell could be considered random, or the time at which they decide to do so, it can depend on human psyche, incomplete information as much as rationnal information or economic datas, but all sorts of somewhat-random event occuring like heatwaves , flooding or sport results.

https://en.wikipedia.org/wiki/Random_walk_hypothesis

In video games it's often time that stocks markets are modeled using purely random or semi random methods. In particular in the game bitburner, which is what made me link the PID to what i did in that game because that's the place i saw combined this 3 way of analyzing a function for an output before and i can't think of other example.

The math i did with that game i found out are also used in some model for real life finance under specific assumptions such as the random walk and others which sometimes relate sometimes makes no sense in relation with the PID.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: PID controller

Post by Qon »

raidho36 wrote: ↑Tue Oct 17, 2023 6:08 pm That's a lot of pedantry for making no point at all; If I were to spell out every asterisk this would be an 800 page book. Better yet, you say I make wrong statements with no basis, without backing any of that up yourself.
I did quote some sources. I did provide reasoning.
raidho36 wrote: ↑Tue Oct 17, 2023 6:08 pm
Qon wrote: ↑Tue Oct 17, 2023 5:38 pm
Well I'll have you know I analyzed about a decade worth of stock market data. I made up all sorts of ways of applying autoregressions and it all came out empty. Most notably the table of odds of price going up or down (binary) depending on the previous pattern - the entire grid came out as 50/50. And so did SGD data-fitted technical analysis indicators, which were allowed to be composed of all sorts of equations, not just the known ones, for completeness sake: humans can't think of everything but a machine combing through possible permutations - can. Maybe a DLNN can figure out something with better accuracy than 50% (i.e. zero ability to make a prediction) but how it's able to do that is firmly outside the realm of human comprehension.
Seems completely reasonable.
raidho36 wrote: ↑Tue Oct 17, 2023 6:08 pm The way PID controller can even be used here is to maintain a stock's price at a steady level by buying and selling arbitrary amounts of it. PID controllers don't model their respective system, they compensate for external forces acting upon that system.
Yeah they are meant to be used to calculate the force necessary to maintain target value. And they don't really form a model for the system directly. But they are a kind of model of how to stabilize the system. Tuning the P, I and D values is a rough approximation of the dynamics of the system, a model of it. And the accumulator for the integration is tuning itself to the target, it is formed from experience of the system, the PID controller models the average reaction needed to compensate for the forces the system requires to maintain equilibrium. Since this reaction must be equal (though opposite) the forces on the system to stabilize the accumulator and the system, it is actually modeling the system. Though only in a single dimension.

And the pid controller doesn't need to be set to control the price, it might be to used to control something else like share of portfolio invested in a particular stock to maintain equal value (or some risk adjusted value or other metric). Then the PID controller will model the trends of the price (successfully during periods of stable linear increase or decrease) in an environment where transaction lag would otherwise mean that the portfolio would be behind the actual target investment level.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: PID controller

Post by Qon »

mmmPI wrote: ↑Tue Oct 17, 2023 6:27 pm
Qon wrote: ↑Tue Oct 17, 2023 5:38 pm Stock prices are what people choose to buy and sell for. That's not random, that's cause and effect.
Yes and no, the coin flip is cause and effect too, yet it's considered random. The possibility to know all the causes and predict the effect can be beyond realm of our perception and as such we can choose to use other model to gain useful knowledge.

What people choose to buy and sell could be considered random, or the time at which they decide to do so, it can depend on human psyche, incomplete information as much as rationnal information or economic datas, but all sorts of somewhat-random event occuring like heatwaves , flooding or sport results.

https://en.wikipedia.org/wiki/Random_walk_hypothesis

In video games it's often time that stocks markets are modeled using purely random or semi random methods. In particular in the game bitburner, which is what made me link the PID to what i did in that game because that's the place i saw combined this 3 way of analyzing a function for an output before and i can't think of other example.

The math i did with that game i found out are also used in some model for real life finance under specific assumptions such as the random walk and others which sometimes relate sometimes makes no sense in relation with the PID.
First you completely skipped the context of what I responded too. My issue is with Raiho36 saying it is COMPLETELY random, that it completely lacks any causal relationship with our universe. So you just cut off the part right before that is the reason why what I said makes sense. So with the context of what I respond to it would look more like this:
Qon wrote: ↑Tue Oct 17, 2023 5:38 pm
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Real stock markets are COMPLETELY random
Stock prices are what people choose to buy and sell for. That's not random, that's cause and effect.
And where did you cut off the quote to inject your response? Right before where I say the SAME THING YOU SAID TO ME.

Qon wrote: ↑Tue Oct 17, 2023 5:38 pm
raidho36 wrote: ↑Wed Oct 11, 2023 3:12 pm Real stock markets are completely random
Stock prices are what people choose to buy and sell for. That's not random, that's cause and effect. It can be modeled as a random process to abstract away the details we don't know when dealing with a lack of information on the people involved and the events related to the company, even more so with more than a handful of people.
Saying it is completely random leaves no space for any explanation of causal events in the world.
Yes a dice is random. But it isn't "completely" random, there's a physical dice following the physical laws. Completely random means no knowledge about the world state and dice before the throw or any laws of physics have any impact at all on what the outcome will be.
Read the parts in italics. Did you add anything to what I just said? No, you just said what I said, as a response to me. :roll:

Look at what I said which you responded to but cut out of the quote on me to make me look dumb:
mmmPI wrote: ↑Tue Oct 17, 2023 6:27 pm
Qon wrote: ↑Tue Oct 17, 2023 5:38 pm Yes a dice is random. But it isn't "completely" random, there's a physical dice following the physical laws.
It can be modeled as a random process to abstract away the details we don't know when dealing with a lack of information
Yes and no, the coin flip is cause and effect too, yet it's considered random. The possibility to know all the causes and predict the effect can be beyond realm of our perception and as such we can choose to use other model to gain useful knowledge.
Seems like you learned about randomness from me and then try to pretend I don't know what it is. And then you spit my example back to me with a 2 sided dice as if it's something completely different.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
raidho36
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Wed Jun 01, 2016 2:08 pm
Contact:

Re: PID controller

Post by raidho36 »

Qon wrote: ↑Tue Oct 17, 2023 7:08 pm Stock prices are what people choose to buy and sell for. That's not random, that's cause and effect.
Only if you consider it "not random" if you were able to retroactively rationalize it. The way I used word "random" is to mean "you have no way of predicting the outcome". As far as stock markets go, you can't even model the distribution of possible outcomes, as you could with a dice roll. That would be great if you could at least make stochastic strategies that reliably work over long periods of time, but even that isn't practically possible.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: PID controller

Post by mmmPI »

Qon wrote: ↑Tue Oct 17, 2023 7:08 pm Look at what I said which you responded to but cut out of the quote on me to make me look dumb:
I'm sorry if you feel i was trying to make you look dumb. That's was not my goal nor what i think.

I had said about dices earlier
mmmPI wrote: ↑Thu Oct 12, 2023 10:29 am
Yes and no , in factorio the quantity of steam in tanks would be following the same rules, going from 0 to 0 and completly random in the middle from the PID point of view. Yet it would be able to modulate the refueling according to solar cycle if you have some solar pannel, and so despite the occasionnal spike in consumption caused by waves of biters eventually due to the feedback loop mechanism. ( you could eventually somehow tell it's night time with some degree of confidence when the pid is telling you to increase refuel periodically by the same amount if you have say enough solar pannel to cover 50% of your need at daytime and big biter waves/noise is only 10% surplus those ratios seems like it would yield a very visible sin-looking like consumption of fuel).

This is the underlying assumption of the existence of "trend" and "trend reversal", which is not the same as random walk, both are needed in the case of the betting algo ( or the linked model earlier) .In real life they only know they had wrong assumptions when model fail, which is a good opportunity to make a new model which will fail eventually unless we stop evolving i suppose :roll: I'd rather play video games :)

If you take 1 dice, and roll, add that number, then roll , subtract that number and repeat. Then there is no trend, model wouldn't work as one assumption is not respected although although the random walk is.

Now suppose some rules that will yield a trend-like behavior : if you reach 12 you are allowed to add 1 point to each following result , and -12 you remove 1 point in each following result. That's 1 in the trend counter. Trend counter reset at 10.

Suddenly you have a model where by measuring you can detect the existence of trend despite the randomness of each dice roll. If you tailor your model to a specific game / fixed settings you can achieve surprinsingly good results vs the seemingly chaotic nature of the measures.

Then you said pretty much the same thing ! but you said it as if it was contradicting the use of the PID and adressed the comment to raidho36, so i thought it was a mistake because i understood raidho36's position as skeptical that PID could be used for stock market prediction. And that it was me that was trying to explain why i saw similarities between PID and some math used for stock market.
Qon wrote: ↑Tue Oct 17, 2023 7:08 pm Seems like you learned about randomness from me and then try to pretend I don't know what it is. And then you spit my example back to me with a 2 sided dice as if it's something completely different.
I didn't realize i was paraphrasing you, because to me i was only paraphrasing me :s

It is a good example :)

but i thought i was supporting a different conclusion

Qon wrote: ↑Tue Oct 17, 2023 6:52 pm And the pid controller doesn't need to be set to control the price, it might be to used to control something else like share of portfolio invested in a particular stock to maintain equal value (or some risk adjusted value or other metric). Then the PID controller will model the trends of the price (successfully during periods of stable linear increase or decrease) in an environment where transaction lag would otherwise mean that the portfolio would be behind the actual target investment level.
I agree with that :D

That's how it worked for me in the game bit burner, you can buy "long" position, and if the price increase, when you sell your position you earn the difference, if the price has deceased you get back less money than your initial investment.
Or "short" position that work the other way. you bet on a price decrease.

One strategy is to invest only in 1 stock, and split your money between "long" and "short" position. ( "hedging") . And then you use PID like math to control the ratio based on what you see the price doing and predict. proportionnal is useful to see the magnitude of increase of decrease, derivative to see trend inversion, and integral to see history or cycle and so despite random noise of daily transactions. if you configure the numbers properly and that the market doesn't evolve ( like in a video game where rules are written once unlike real life where model are just model that need be changed when too much disruption occur in environment ) it worked for me.

For the mall i found it fun because the "overshoot" of the control mechanism is somewhat a positive and a risk, when i take a stack of wire, the PID record a very brutal drop in copper and circuit in returning belt and overcompensate for a while compared to attempting to maintain the same amount.

Say target is 20 green circuit, if the returning belt is empty, ( average 0 on 10 belts) the pid-controlled mall will try to cram 20 of the item in only the 10 incoming belts and even a little more like 21 or 22, welcome overshoot.
But when the system is stable and no circuit is consumed, the PID-controlled mall sees 10 circuits in the returning belt, and as such only put 10 in the incoming belts.

What makes it put 10 15 or 20 item is the frequency of pulse that enable the belts. I don't know how many pulse are required for 20 or 15 or 10 item, that's PID controlled i just set how many i want to have on the belts, and the pid increase the frequence untill it's reached, or decrease in case of excess.

Without the collector loop to re-inject material, it could never get rid of excess material, but this part can jam if too much excess was injected earlier.

I think it ressemble steam that is always consumed a little. In case of excess fuel for steam you waste energy, but for the mall it clogs ( which happened twice , and lead me to tweak the P value a little ).
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: PID controller

Post by Qon »

raidho36 wrote: ↑Tue Oct 17, 2023 7:41 pm
Qon wrote: ↑Tue Oct 17, 2023 7:08 pm Stock prices are what people choose to buy and sell for. That's not random, that's cause and effect.
Only if you consider it "not random" if you were able to retroactively rationalize it. The way I used word "random" is to mean "you have no way of predicting the outcome".
You said COMPLETELY random. You seem very willing to pretend the COMPLETELY part never happened. Is it because you realize that saying that is COMPLETELY explained by randomness alone and not making space for anything else is not a defensible position, but you prefer not to admit it?
I have admitted that a random variable can be used to model the behavior. But modeling something and saying that the process is definitely COMPLETELY random are different things.
raidho36 wrote: ↑Tue Oct 17, 2023 7:41 pm The way I used word "random" is to mean "you have no way of predicting the outcome". As far as stock markets go, you can't even model the distribution of possible outcomes, as you could with a dice roll.
Well I can predict (obviously not with perfect accuracy) future events. Either with an explicit model or with my intuition, implicit world model from experience. Both learned from the world. I can predict how many seconds it will take the thrown apple to hit the ground, with an equation or just guessing with a brain evolved to predict parabolas and the physical laws immediate effects (as they relate to everyday interactions). I can predict which company will rise and fall in stock price as a spreadsheet modeling of the production numbers and sales that seem reasonable from the investments done today and their past success scaling and other world events that can impact their ability or consumer sentiment. And those underlying processes are also things that can be predicted.

Saying you can't model the distribution of possible outcomes sounds like you are stuck trying to make the random variable model be the solution.

But you can model the distribution of outcomes, if you decide on actual world events that are relevant to model and how they will likely impact the company/stock value. And for those you might assume some probability distribution of event happening or not, or further model underlying causes. Recurse as deep as you think you need. Then do a monte carlo simulation on base events and run the functions on how base events causes effects.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: PID controller

Post by Qon »

mmmPI wrote: ↑Tue Oct 17, 2023 8:13 pm
Qon wrote: ↑Tue Oct 17, 2023 7:08 pm Look at what I said which you responded to but cut out of the quote on me to make me look dumb:
I'm sorry if you feel i was trying to make you look dumb. That's was not my goal nor what i think.
Apology accepted. I believe you.
mmmPI wrote: ↑Tue Oct 17, 2023 8:13 pm I didn't realize i was paraphrasing you, because to me i was only paraphrasing me :s
I think we just missed the context of eachother. When I wrote my reply to Raiho36 I was only responding to him. But you had written about the randomness or not of dice before. So when you responded to me and extended your earlier discussion I thought you meant to say that the part I left out was what I had missed.
mmmPI wrote: ↑Tue Oct 17, 2023 8:13 pm but you said it as if it was contradicting the use of the PID and adressed the comment to raidho36, so i thought it was a mistake because i understood raidho36's position as skeptical that PID could be used for stock market prediction. And that it was me that was trying to explain why i saw similarities between PID and some math used for stock market.
And yeah I completely missed who had what opinion on if PID for stock markets would work. Though in my defense that wasn't the point of the post in which I confused that, I was trying to focus on if actual stock markets are random processes ONLY, without ties to the physical world.

I think it works for the simulated market you verified it to work for you. And I think it doesn't work for the actual stock market data which Raidho36 tested all kinds of models and verified those to not work. So you both seem correct on that. :)

mmmPI wrote: ↑Tue Oct 17, 2023 8:13 pm I agree with that :D

That's how it worked for me in [...]
Yup, yup. Interesting use cases. And I agree with the world not evolving being the reason a PID can be tuned to provide the profits in the game.

How is the belt loop affected by the control signals for output being dropped because the belt doesn't have capacity to accept more input at the rate the control signal says? Or is the control signal stored in some accumulator and ticked off for each item measured to actually be sent in according to the control signal? And how is a negative control signal dealt with then?
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: PID controller

Post by mmmPI »

Qon wrote: ↑Tue Oct 17, 2023 8:54 pm I think we just missed the context of eachother.
Clearly i had not properly read all your argument and repeated part of it without noticing the context problem.
Qon wrote: ↑Tue Oct 17, 2023 8:54 pm
I think it works for the simulated market you verified it to work for you. And I think it doesn't work for the actual stock market data which Raidho36 tested all kinds of models and verified those to not work. So you both seem correct on that. :)
And the unendding debate is why ? :D
I was trying to focus on if actual stock markets are random processes ONLY, without ties to the physical world.
I'm not saying this is the case yes/no definite answer, i understand this is a controversial topic :D but there are models that have "yes" opinion on this, and model that have "no" opinion on this. From my research related to video games and how it's done in real life i'm no finance / market expert :)
Qon wrote: ↑Tue Oct 17, 2023 8:29 pm You said COMPLETELY random. You seem very willing to pretend the COMPLETELY part never happened. Is it because you realize that saying that is COMPLETELY explained by randomness alone and not making space for anything else is not a defensible position, but you prefer not to admit it?
I have admitted that a random variable can be used to model the behavior. But modeling something and saying that the process is definitely COMPLETELY random are different things.
i know this wasn't adressed to me but hey here's my understanding of it if it can avoid future confusion :) :

I understood COMPLETLY random as a strong disclaimer against the thought that PID are magic thing to make you rich trading crypto-nft or something adressed to me.

And/ or from a philosophic standpoint, completing this disclaimer that truly random event can eventually decide everything for real life market, like volcanoes or solar eruptions , climate at the big bang noise level of random. The completly random apart from 0 at the beginning and to 0 at the end is philosophical to me because shares aren't free the first day at stock market, but the share of the future companies that do not exist yet are worth 0 on those markets, and the shares of some companies that are not longer existing are also worth 0.

In such case the steam value in tanks also depend on those truly random event and is from 0 to 0, because one quantum bitflip and the quantity is NaN, or that before the game there is nothing of interest to record, and after the game too and everything in between is random.

so yes and no ^^

The PID use a random variable to model things. And some economic model are based on the assumptions that price change is (akin to) COMPLETELY random. Even though those are two different things, it is also their similarity (in my eyes).

Because those specific models do not try to make any correlation from real life data considering those can't ever be enough to be source of accurate predictions based on cause=>effect understanding and instead do something similar to creating a random variable every time to model variations of price and try to write rules from observation on that random variable.
Qon wrote: ↑Tue Oct 17, 2023 8:29 pm But you can model the distribution of outcomes, if you decide on actual world events that are relevant to model and how they will likely impact the company/stock value. And for those you might assume some probability distribution of event happening or not, or further model underlying causes. Recurse as deep as you think you need. Then do a monte carlo simulation on base events and run the functions on how base events causes effects.
Deciding on which actual world events are relevant is the source of most mistake (imo ). Math are working in their own world, and choosing which number to crunch may not be possible. The paradox you will probably recognize if you need to consider 10 000 000 000 parameter ( humans )and for each of them a number of parameter that is enough to describe them entirely for prediction to work, it may require more time than available for the universe to compute for a machine that would be composed of all the matter of the universe.

Or something like it will always take 1 minute to predict what will happen 1 second later because the computing power availble is increasing at the same rate (or slower) than the complexity and interconnection of our world.

You can ALSO model the distribution of outcome without deciding on any actual world event relevancy, just by looking at the previous measurement( PID-like) and you can still use some probabilistic method to give range of likelyhood for future measurement that's how options are priced in real life as far as i understood.
( you know you can't predict things that never occured before bad point but you never wrongly associate one cause to an effect or forgot to list one parameter . good point)

mmmPI wrote: ↑Tue Oct 17, 2023 8:13 pm I agree with that :D

That's how it worked for me in [...]


Yup, yup. Interesting use cases. And I agree with the world not evolving being the reason a PID can be tuned to provide the profits in the game.

How is the belt loop affected by the control signals for output being dropped because the belt doesn't have capacity to accept more input at the rate the control signal says? Or is the control signal stored in some accumulator and ticked off for each item measured to actually be sent in according to the control signal? And how is a negative control signal dealt with then?

So the belt loop i can extend it indefinitly, i do not control the quantity of item, i control the density in the first few and last segment.

Given that the density is calculated on a define number of segment as a player i need to set my combined target value to not exceed the quantity that +/- 20 belts can hold if i control the 10 last and 10 first segment.

The PID therefore "measure" value with a little lag of the lengh of the loop. Since if the ressources are removed in the 11th belt, it's only when it reach the 10th from the end that is "seen".

In other word when ressources are removed it create a "depleted segment" that loop around, and when it is located in the few of the last segment of the loop read by PID, it makes the PID try to force more material on the early segment to compensate. ( since target is for :"end-segments+early segment") which means more of those ressource for next seconds but only in the limit of twice the target fixed and a little overshoot.

When the belt cannot accept more input it is mechanically dealt with, the different priority splitter that insert material on the loop make it so that the PID pulse are allowing a belt to load material onto another belt where there is no room and so the pid pulse faster and faster until it can reach target.

A belt enabled by pulse is going to be 50% slower than a regular belt at best (considering no 2 consecutive pulse ) so high troughput is not really a concern, i can't get too high throughput, that's why i'm making shotguns and wires things i don't need a lot of rather than inserters or belts :D

Negative signal is the risk, mainly because a long loop means many item would be sent "too many", it translate into an absence of pulse being sent from the PID to the feeder belts, which means they stay closed and the excess material is taken away by some splitters and made ready to be re-injected in priority over new material when the pid would pulse again.

The amount of "excess" material that can be stored like that is also function of the overshoot from the PID when trying to regulate the quantity, not only from the long loop.

At first when i asked for 30 iron it was getting me 40 to 45 most often. So i halved P value, once or twice ,and then when i asked for 30 i was getting often time 35 it was visibly better. So i thought it was good enough, but it got stuck once because the excess iron couldn't be stored in the reinjection in priority lane, there was too much and it blocked the other material from the main loop.

So i reduced limit to 20 and i was getting 25 or so, so i reduced again the P value. When adding new material i also sometimes reduced the target for iron . Currently p=2K d=25K i=1 with 15 15 10 5 5 5 3 3) being the quantity requested of different 8 item for the mall. Sometimes it can get up to 22 instead of the target at 15 for a material when i take full stacks of all combinators from the mall that's my worst case scenario. And the buffer for extra material is more than 90 per material, that's seem plenty.

I will add new weapons when i unlock them but i'm playing with the hidden tech tree and i don't know their receipe yet. This military mall is branching off my main bus with some room left to add more materials ( like 8 belts at least and i'm using half belts so 16 different item like explosives or uranium), and possibility to extend in the perpendicular direction as much as i want for explosive shells , and artillery shell ...

I can always have a look at the accumulator for the integral, which tells me if my targets are historically not met, which may mean i'm setting target too high for the throughput of a half-red belt throttled.
raidho36
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Wed Jun 01, 2016 2:08 pm
Contact:

Re: PID controller

Post by raidho36 »

Qon wrote: ↑Tue Oct 17, 2023 8:54 pm
All I'm seeing is a lot of "technically in principle..." and not a whole lot of "in practical experience". Like technically in principle during programming you don't need to validate function inputs because you can simply assume that they were generated as valid in the first place - you just need to write code without any bugs and oversights in it. Very obviously this is not a meaningful thing to say. You're also conflating chaotic systems and random ones. Chaotic systems can be 100% accurately predicted by extrapolating initial state (you merely need to precisely know 100% of it). Random systems cannot be predicted because deviations materialize out of nowhere. Which is to say, true chaotic systems can only be purely mathematical, whereas everything in reality is random. In order to make an informed prediction of stock markets you'd need to precisely know 100% of metal state of 100% of people who engage in stock trading, also 100% of software which does it alongside. Besides being monumentally silly on its own, this idea is destroyed completely when you consider the fact that specific timing and pattern of firing of neurons depends on quantum fluctuations, and computer RNGs may directly tap into quantum effects as source of entropy. In other words, you seemingly think that if you can rationalize something retroactively, then it wasn't random (rationalization itself doesn't even needs to be valid or complete, you only add it insofar as to convince yourself).

In any case, I'd appreciate if this thread-unrelated conversation was taken to the off-topic board.
Koub
Global Moderator
Global Moderator
Posts: 7766
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: PID controller thread off topic fork

Post by Koub »

[Koub] Split from this thread : viewtopic.php?f=193&t=109118
@Qon, mmmPI : sorry to be brutal, but I'm amazed at how much time you can both spend arguing endlessly on random topics. Maybe you have too much free time and you could consider using it in a more productive way.
Koub - Please consider English is not my native language.
aka13
Filter Inserter
Filter Inserter
Posts: 793
Joined: Sun Sep 29, 2013 1:18 pm
Contact:

Re: PID controller thread off topic fork

Post by aka13 »

Koub wrote: ↑Wed Oct 18, 2023 7:00 am [Koub] Split from this thread : viewtopic.php?f=193&t=109118
@Qon, mmmPI : sorry to be brutal, but I'm amazed at how much time you can both spend arguing endlessly on random topics. Maybe you have too much free time and you could consider using it in a more productive way.
I am not amazed how every topic is full of such bullshit by the 3 usual posters. Maybe it IS time to move on to discord.
Pony/Furfag avatar? Opinion discarded.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: PID controller thread off topic fork

Post by mmmPI »

Koub wrote: ↑Wed Oct 18, 2023 7:00 am mmmPI : sorry to be brutal, but I'm amazed at how much time you can both spend arguing endlessly on random topics. Maybe you have too much free time and you could consider using it in a more productive way.
Hey Koub i am not too bothered by your so-called brutality i've seen far worse and i don't hold a grudge. I can see how the thread is off-topic. Sorry if i caused the thread to derail with my repeated comparaison with stock markets and finance that was not my intention.

I really like learning new things and make sure i organise myself to have lots of time for it. It's not so amazing it's mostly good time mamagement that allow me to have that much time for discussing topics i find interesting unfortunatly sometimes when or where it's not appropriate to do so.

When i see the others things i do to spend my time though, i don't think this is the least productive way, by far , you'd be horified :lol:
aka13 wrote: ↑Wed Oct 18, 2023 7:26 am I am not amazed how every topic is full of such bullshit by the 3 usual posters. Maybe it IS time to move on to discord.
Did you really join a discussion between 3 people to say that they usually post bullshit ? You could have spare yourself some trouble and not read everything if you were not interested. That's an example of far worse use of time to me and that's not really a good argument in favor of discord if you aimed at illustrating the kind of normal interaction people are expected to have there.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: PID controller

Post by Qon »

raidho36 wrote: ↑Wed Oct 18, 2023 6:00 am
Qon wrote: ↑Tue Oct 17, 2023 8:54 pm
All I'm seeing is a lot of "technically in principle..." and not a whole lot of "in practical experience".
You quoted a post not directed to you, unrelated to your response and you removed all text. Are you confused?
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: PID controller thread off topic fork

Post by mmmPI »

Wanna hear Benoit Mandelbrot thought on the topic ? Yeah the inventor of fractal, turns out he spent quite some time of his life thinking about market modeling, given the historical context of his life and years of activity, seeing revolution in electronic related to stock trading.

Turns out the nature of how to understand the curve of stock price created a "heated" debate in real life too when he heavily critized the model i cited using PID-math like to price options.

Roughly the assumption of random walk means that day to day variation could be represented like bell curve where most variations are in the middle, and are similar in magnitude and constitute the majority of what is to be taken into account to predict prices. (where using random variable model to use PID like math work nicely ). Whereas the critic from Mandelbrot, in an overly simplified fashion would tend to say that unlike bell curves ,in real life markets what is more important to predict accuratly/model , are the rare events on what would be the very edge of that bell curve,their magnitude overpowering their low frenquency, leading to a more chaotic system, making it an illusion/much harder to count on law of large number for prediction.

On the video the Black-Scholes model is not referred to explicitly, but every time he refers to the "ideas of Bachelier", it is the idea that one can use brownien-motion analogies in finance.( and then a bell curve to describe variations ).

https://www.youtube.com/watch?v=vxbxXBrOPS8

Now considering the PID controller, basically it would be someone saying : it works for the factory, with the extreme of "everything is automated thanks to it" and someone else saying, a real factory sometimes run-out of power or is modified/upgraded, disrupted, shut-down, and when this happen human intervention is required with the extreme "the PID controller therefore doesn't work for the factory".

Sorry Koub if you have to read all this to make sure i'm just sharing unproductive talk and not harassing anyone but it made me wonder if Mandelbrot's collegue at IBM were thinking of him being non-productive when he was working on fractals or if it was his math peers who thought he was being non-productive when trying to argue with finance people. Since the thread is now off-topic , i figure i could share this apology of serendipity :)
Post Reply

Return to β€œOff topic”