Forums > Pricing & Modelling > stupidity and parametric forms

 Page 1 of 1
Display using:
 Strange Total Posts: 1577 Joined: Jun 2004
 Posted: 2019-03-23 17:18 Please don't laugh. I am trying to convert an "if - then" statement into a parametric form that would allow for a smoothed transition between states. It's probably something fairly simple, but I am completely blanking (seems to happen more and more lately). Here is the gist of the problem in it's current state:A, B are continuous variablesZ is thresholdX is scale valueso I have the following statement in the code:Q = (X if A > 0 and B > Z else 1) x (X if A less than 0 and B less than Z else 1)Obviously, the above not a very optimal way of doing it, since Q changes from 1 to X discretely and I want to avoid that type of behavior. Ideally, it would be some sort of a continuous 2-d function that can be tweaked from a completely discrete state above to a more continuous form via several variables. A simple version is to make a X a linear function of B and keep the conditions above, but that does not get rid of discontinuity wrt to A. “My dear, here we must run as fast as we can, just to stay in place. And if you wish to go anywhere you must run twice as fast as that.”
 gaj Total Posts: 48 Joined: Apr 2018
 Posted: 2019-03-23 17:47 The last part of the formula for Q is cut off. Anyway the first part can be written as(A > 0) * (B > Z) * (X-1) + 1Then you can replace the binary variables with sigmoid:sigmoid(A) * sigmoid(B - Z) * (X - 1) + 1
 Strange Total Posts: 1577 Joined: Jun 2004
 Posted: 2019-03-23 17:57 Thanks! corrected it - it's essentially the same statement in reverse (if both A and B are less than zero and Z respectively).The sigmoid version is interesting (indeed it removes the discontinuity with respect to both B and A) and I I am guessing I can extend it to have continuous decay from 1 instead of Xsigmoid(A) * sigmoid(B - Z) * ( decay(B) - 1) + 1 “My dear, here we must run as fast as we can, just to stay in place. And if you wish to go anywhere you must run twice as fast as that.”
 nikol Total Posts: 770 Joined: Jun 2005
 Posted: 2019-03-23 21:57 This algebra is developed in Fuzzy logic
 TonyC Nuclear Energy Trader Total Posts: 1307 Joined: May 2004
 Posted: 2019-03-24 04:51 the "sigmoid' function that is used in the backpropagation algorithm of neural networks is a very smooth transition between 0 and 1 ... and good explanations are in every introductory neural network machine learning text.and if you think it's weird that I'm replying at a quarter of midnight on a Saturday in New York, it's even weirder that I'm actually replying at a quarter of 5 a.m. on a Sunday in Vernazza flaneur/boulevardier/remittance man/energy trader
 TonyC Nuclear Energy Trader Total Posts: 1307 Joined: May 2004
 Posted: 2019-03-24 04:52 oh wait, you already mentioned sigmoid functions, which means my prior reply is superfluous and that I am an idiot ...... or at least I'm an idiot 5 a.m. in the morning flaneur/boulevardier/remittance man/energy trader
 nikol Total Posts: 770 Joined: Jun 2005
 Posted: 2019-03-24 10:51 TonyC: that's a wide-spread phenomenon - stupidity with positive feedback. ))
 Page 1 of 1