#modeling

1 messages Ā· Page 5 of 1

jagged palm
#
lean walrus
#

I have two very offensive engineering moments

#

One was a few years ago, where I was running a simulation and my result was "off" on the order of 10^4

#

("Off" additively i.e. +- c*10^4)

#

But we were working on the order of 10^9

#

So I just said that was good enough and called it a day

#

One was more recent

#

I was running a numerical simulation and had to filter out values "near zero" and duplicate values

#

I would've tried to use like 10^(-12) \equiv 0 but my numbers were too big relative to that so I had to use 10^(-3) šŸ’€ I said if the difference of two numbers was within a thousandth of each other (or if either number was less than a thousandth) it was "0"

#

That one felt pretty silly

#

But it worked 😁

lean walrus
#

I tried looking for it in our DMs but it wasn't there, I don't remember where it happened. I just remember I was talking to you when it happened šŸ˜›

spice forge
lean walrus
#

dawg what that even mean

jagged palm
lean walrus
#

Ya you’re right, but I guess to the ā€œaverage personā€ hearing that you’re 50,000 - 90,000 [units] off sounds like a lot 🤣 I was certainly not used to doing that at the time

jagged palm
#

It might be really bad haha

#

If you're making a bridge and your estimate of how many kilos it can take is off by that much, I'm scared

#

If you're estimating the number of kilometers to the middle of the Milky Way for general order of magnitude, I'm impressed if you nailed it down that far

signal vault
#

I have a real life engineering problem that I think math could help solve if anyone has any ideas:

there is wastewater going out to the city and the pH of this water is continuously monitored. If the pH drops below 5 then a valve upstream of the pH probe closes so that the water can be reprocessed.

The problem is that the pH probe occurs after the shutoff valve so by the time the pH is below 5 there is a lot of bad water that gets through even if the valve closes instantly.

I want to use mathematical tools on the pH signal to predict a below 5pH event before it happens so I can shut the valve early

#

My initial thoughts were to use autocorrelation but I’m not really sure what the best tools would be. I though that autocorrelation could tell me how much the signal correlates with itself over time

#

So maybe a better way to state the problem:

I have a continuous time signal which is mostly low frequency ā€˜noise’ (mostly stationary) but occasionally there will be a very sharp drop. I want to know what mathematical tools could help me predict the drop.

upper stump
#

Are you working with real data

#

Are there any signals in the data before a ph drop

wide flame
#

how fast is the drop wrt volume and valve deltas? are there probes/readings from upstream processes? you might not even need to "predict" also, unless rule based systems have already been evaluated

signal vault
#

And then this is the flow rate, pH signal, and derivative of pH signal over like 30 hours

signal vault
#

But regardless of the real world fixes of having more probes, I was more curious about what I could do given the information I have now

#

The system goes

Tank A (acid buffer) —> tank B (base buffer) —> shutoff valve —> flume pH probe (the main signal I am getting)

wide flame
#

personally, i would need more chemistry knowledge, but why can you not just directly calculate the expected ph if you have readings from both buffers?

upper stump
#

Do you know mechanistically why the pH drops

signal vault
#

Yea so this is for a factory where we do anodizing which takes aluminum parts and dips them in a bunch of chemicals to make them shiny chrome or shiny black. Depending on the levels of the tanks or how dirty the tanks ā€˜water is’ the tanks get sent to wastewater through A and B.

signal vault
#

Here are signals from one particular event

#

The red is what I am trying to prevent

#

The system works okay right now but the small red part is technically illegal so I want to fix it

wide flame
#

step 1 is to tell your manager to tell leadership to invest in better sensors + placement yesterday

#

i imagine that some ac model could do decent, esp given (from my understanding) you are really trying to determine when the water gets too "dirty"

signal vault
#

I know I’m gonna try that but they insist that the little spill to the city is not a big deal and so they arnt gonna spend any money. So my choices are throw them under the bus and lose my job or fix it without spending money by using an algorithm

#

But I’m also highly interested in the math that i could to fix this because it’s pretty cool to solve problems with an algorithm

upper stump
#

Anyways

#

Back to the math

signal vault
#

Like maybe I wouldn’t get fired but then I would be bullied or never promoted or something idk

wide flame
#

actually, have you looked at the delta distribution for time between events? unless it is insane, there is a world where you can just say, if x above y, and > N hours since last event, pause the flow for t

#

not saying modeling isnt the "right" answer, but you usually want to avoid it if possible

#

(in corporate, ime)

upper stump
# signal vault

Do you know why there is the wiggliness in the third graph here

signal vault
signal vault
#

Because if I had to guess about that it’s because the electrical sensor is not always submerged and is being hit by waves within the pipe

#

And also electrical noise from the chemicals being used or something

#

And also tanks A and B are ā€˜automatically controlled’ so if they detect high or low pH they dump acid or base into the tanks respectively.

wide flame
#

do you have data for those processes?

#

that seems rather significant

#

i would hope that the control system is logging events

signal vault
# wide flame do you have data for those processes?

I just started recording the flow rate and pH of this system. Everything else is relay logic so at best it’s ā€œif tank A pH is above X for Y seconds, dump acid for Z secondsā€ all completely fixed

#

This system was on the dinosaur level and i started logging the pH signals and flow rate to a database and that’s when I realized we were dumping out bad water

#

And now my systems data is being fudged and then sent to the city …

wide flame
terse adder
#

can I ask questions in this channel about linear regression and time series?

jagged palm
#

Go ahead and ask

lean walrus
#

me when the intersection of two domains is donated by the + operator (idk just reads easier to me)

jagged palm
#

That is confusing to me lol I would have expected that + means union

#

in the context of that picture it makes sense tho

upper stump
#

<@&268886789983436800> spammed in multiple channels

sand onyx
#

Please don’t advertise here or cross post your messages.

golden saddle
lean walrus
#

Silly question but how would you model the following phenomenon?

#

Say a mother is 29 when she gives birth, and take her child to be 1 year old at birth (very common in Asia)

#

Her age is 29x the child's age

#

Let one year pass; the child is now 2, and the mother is now 30, making her 15x the child's age

#

3 and 31 make her (10 + 1/3)x the age, and you get the idea

#

How can I plot/study the ratio of the mother's age to the child's age as a function of time?

upper stump
#

(29+t)/(1+t)

lean walrus
#

Something something (mother + x*t)/(son + x*t) I assume?

#

Okay

#

Yes

#

LOL

#

Thank you

#

I feel silly

graceful kindle
#

What modeling is about?

#

I'm new to it

jagged palm
grizzled turret
graceful kindle
#

What resource is recommended to learn modeling?

upper stump
#

Why do you want to learn about mathematical modeling

jagged palm
#

Do you have something in particular you're trying to gain understanding about via mathematical modeling?

graceful kindle
graceful kindle
grizzled turret
#

Also models often (but not always) arise from differential equations, so you may wanna have at least an introductory understanding of that area of math as well

upper stump
graceful kindle
graceful kindle
graceful kindle
lean walrus
# graceful kindle Idk, cause idk what modeling is

This will be a bit vague because I'm learning about it as I go, but I can demonstrate an example of modeling that I am currently doing now. Perhaps that may give you an idea of what modeling "looks like" and how it can be applied

#

So I'm working on a "personal finance simulator" in Excel, where the idea is that I input in a few numbers and it shows me how my balances and expenditures evolve over time

#

There is already a very simple model of this

#

The idea is that you start off with an initial balance P, define a rate of return r, then define a timespan t and a compounding frequency n within that timespan (how often your rate of return applies to your balance)

#

Then, the final balance F after t number of timespans is given by

wanton ravineBOT
#

feather
Compile Error! Click the errors reaction for more information.
(You may edit your message to recompile.)

lean walrus
#

So this models that situation because you take your rate and divide it by the number of times it compounds per year, giving you the effective rate at which it compounds on each compounding period (this is the 1 + r/n). Then you take this over the number of compounding periods across the timespan (this is the exponent nt), and since that's all compounding on your principal, you scale it by P

#

So there's a simple and effective example of a model right there

#

But we can make this even more detailed

#

Consider the stock market; while you can form averages of the rate of return over a year (this is 10% afaik), the actual number changes depending on the economic situation

#

You might get 4% returns one year and 16% another and -9% the next

lean walrus
#

So your principal also grows with time now

lean walrus
#

Let's step it up another level

lean walrus
#

I'll give you the context of mine, as an example

#

I currently live with my parents; they pay the mortgage, they pay for food, they pay utility bills. They take care of all the "big stuff", so I really don't spend much money outside of personal expenses

#

So right now I can afford to throw a lot of my savings into my retirement fund

#

So every contribution I make is pretty large (let's say $1000 - $2000 at a time)

#

But now look 5 years in the future

#

I'm probably living alone now, so now I got actual bills to pay

#

That reduces the amount of money I can throw into my fund per contribution, so now I might only be contributing $500 at a time

#

Then maybe one day I unexpectedly get fired

#

Now I can't afford to contribute any money because I have no income - I'll have to live off my savings until I can afford a new job

#

So you see how the size of your contribution, as well as the frequency of how often you contribute, can change depending on your personal financial situation?

#

Now let's look 5 more years into the future

#

I've got a great job again, I'm probably married now, maybe even have some kids

#

I've been saving for a long time and I'm looking at buying a house

#

Well, that's likely gonna require me financing the majority of the house cost

#

But the interest rate my bank gives me on my finance can also depend on the economic state at the time and what the Fed has set their baseline rate to

#

So if I decide to buy at a time when we're in economic situation A, and the rates are high (inflation), that means I'm paying much more over the course of the loan

#

Or we could be in economic situation B (strong economy), and the rate is actually lower than it might typically be!

#

I could have a great credit score and get better rates, or a poor credit score and worse rates

#

Then you have to consider how frequently the economy is changing too

#

Economic parameters tends to be self-correcting towards some mean (exhibit mean reversion), so depending on how long we've been in, say, a recession, my expenses might go up relative to the value of my money (meaning I can contribute less per period), but then the economy starts getting okay again and now my expenses are less relative to the value of my money (meaning I can contribute more per period)

#

The point is, you see how many changing variables there are, and how they can change how much I contribute (or whether I contribute at all)?

#

The economy is stochastic in this sense; you never know what's going to happen next, so while you can make some predictions about how things will evolve, they might go completely another way

#

There's a billion ways you can model this

#

The way I'm choosing is by assuming that at certain ages of my life, I'll be in certain stages of my life (my salary will be x1 at stage 1, x2 at stage 2, my expenses will be e1 at stage 1, e2 at stage 2, etc), so I can "roughly predict" how my personal financial situation might look

#

Then, I've assumed that our economy can be in one of six states: expansion, boom, recession, depression, equilibrium, and stagflation

#

I've written down some important rates that'd affect either my personal expenses or how my retirement fund grows

#

(as you can see, I'm still filling it out)

#

Each rate in each economic regime has three parameters associated with it: a "mean reversion strength", a mean, and a variance

#

(These are the vectors in each table entry)

#

I also have a length column for the approximate length of time any one state might last

#

Then, I've created a Markov table to model the way the economy might switch from one state to another every time it switches (I've defined the switching rate as "once the current regime ends, we switch")

#

I also have inputs associated to my expenses per stage

#

My plan is to then simulate what the economy and my personal financial situation might look like over the course of my life, and how it effects how much I can contribute to my savings and retirement funds

#

(ignore the dates and empty columns, I'm still working on it lol)

#

I'll also create an event manager that will throw in random shock events, like something that causes the economy to want to enter a boom, something that raises my income for the year or lowers it, one-time costs like when I have my wedding and take that money out of my savings, etc

#

So you see how I'm trying to use real-life situations to create a mathematical/programmatic way of simulating real life?

#

In real life my money and expenses and so many other things change depending on my age, family status, a billion things

lean walrus
# lean walrus

So I've modeled that in this way (there's more tables)

lean walrus
#

In real life, you have shock events that change the economy unexpectedly

lean walrus
#

So I'm trying to see how I can structure data and computations to reflect real life situations

strong fox
#

Interesting, will give my 2c later on if I have any 2c

lean walrus
#

I'm by no means financially literate or an expert on money or the economy so this is all just using my very basic knowledge and learning as I go

#

But at least now I can kinda see what might happen over a variety of situations, and I've given myself the flexibility to be able to change my model parameters in a lot of ways; I can change how my personal finance situation evolves, I can change how the economy evolves (somewhat). I can change a lot of things, some of them by editing a few parameters, and others by completely reprogramming my simulator to model real life in a different way

void crystal
# lean walrus I'm by no means financially literate or an expert on money or the economy so thi...

Hi @lean walrus my graduate background revolved around NP-hard problems & category theory; but I got swooped up into the world of finance doing model validation for algorithmic trading strategies.

In order to respect how vauge our understanding we have of aggregated national econometrics.. I suggest you check out Ito's lemma & how stochastic calculus can be applied to orderbook dynamics, etc.. mathematical finance & microstructrue.

void crystal
graceful kindle
lean walrus
#

i hate finite elements

#

my solution go boom boom explode

#

unfortunate.

upper stump
#

Good luck

silent marsh
#

wait no that's actually a thing you can do

#

have you tried doing it backwards \srs

lean walrus
#

Wtf is doing it backwards? Using an implicit solver?

silent marsh
#

wait no i am misremembering things

#

ignore me

lean walrus
#

LOL

#

I know what's causing the issue but not how to fix it kekw

upper stump
#

Some pdes you can solve backwards in time just be reversing the sign of the time derivative

strong fox
#

In any case #modeling's a very applied thing. Sadly that also means a lot of quants and quant math, if not #optimization math come in very typically

In theory you can model a lot of things but unless it's allowed to be very academic, then it's common for finance to come in. Another good #modeling area is epidemiology, which is less quant-sy and more biostats-y, which could be nice

lean walrus
vivid geode
# strong fox In any case <#1055572844114878615>'s a very applied thing. Sadly that also means...

Biological modeling involves a lot more than just epidemiology.

Like, obviously, it’s where people have put a lot of focus (see 2020 and also generally good needing to influence fast action wrt infectious diseases). But it’s been super useful in oncological models of different cancer processes, understanding enzyme kinetics, a zillion different molecular dynamics simulations, protein modeling, the list goes on

#

I’m biased and think math oncology is the best

#

But that’s because that’s my field

jagged palm
#

(Go neuroscience!)

azure jolt
heady bison
#

this is sort of a modeling/numerical inquiry but does anyone know of any information or readings on molecular optimization of API, and also if there is a technique for photopharmaceuticals

lean walrus
#

@strong fox @jagged palm @neat pine Hope you enjoy!

This is my finished draft, got all the base functionality. If you want to try it out make sure macros are enabled and run the RunSimulation macro (or you can just view whatever data is already there without running a macro in case you're worried about security).

I'm hoping to polish it by next weekend 😌

#

Ignore the fact that I am millions in debt by retirement age šŸ’€ I am still debugging and optimizing parameters, most of these are fill-in values

rocky garnet
#

@jagged palm what causes continual learning to work so well in the human brain that doesnt translate to LLMs/neural networks

#

asking since i remember you said you model brain mechanics

jagged palm
jagged palm
# rocky garnet yea catastrophic forgetting

One thing that might be helpful to think about is that the human brain has a ton of innate structure that neural networks don't; this is true on the level of cells (very diverse cell types with specific firing patterns and properties), circuits (the cortex has a "canonical microcircuit"), and systems (the way that different brain areas are connected together). So there's not the same risk of catastrophic forgetting because there's such a strong inductive bias on what is learnable in the first place. The brain also has critical periods, e.g. in language, after which it can dynamically shut down its flexibility to prevent forgetting crucial things.

#

I think this is a big open question though

rocky garnet
#

also another question, do you think AGI will be achieved by modeling the brain or do u think current ML methods r sufficient

jagged palm
#

I know very little about AGI but I am very skeptical about anyone who thinks the way forward is just to keep throwing more compute at things

#

The brain is absurdly more energy efficient than current artificial neural network systems