The second talk is applying MILP method to searching integral distinguishes based on division property for six right-weight work cycles. By Zeng Jun-shan, Wen Dao-jian, Zeng Zhenbao, Dan Dai-lin, talk is given by Zeng Jun-shan. Good afternoon, everyone. My name is Zeng Jun-shan. The title of this talk is applying a MILP method to searching integral distinguishes based on division property for six right-weight work cycles. This is the overview of the talk. Firstly, we will review division property. And then we show how to combine a MILP method with division property. And last, we present a search algorithm and show some applications. First of all, we should take a look of some new launches. For any fixed u, pi ux is a Boolean function. It's divided as the product of some chosen bits of x. And we use vector u to choose the corresponding bits. So if n equals to 4, m equals to 2, pi ux can be computed as 0 to the power of 0 times 1 to the power of 1, and so on. So the value of pi ux equals to 0 in this particular situation. Next, if k and k star are two vectors, if k i is greater than or equal to k i star. So in this case, we will say k is greater than or equal to k star. Otherwise, we say k is not greater than or equal to k star. Now we review the definition of division property. Division property is introduced by Toto at Eurocrypto 2015. It's a generalized integrator property. Let x be a subset of f2n to the power of m, and k i be m dimensional vectors. x has the division property dk0k1 to kq minus 1. If the sum of pi ux equals to 0, for all u belongs to this set. In this expression, w u represents the vectorial ham weight of u, and wt u0 represents the ham weight of u0. So now, with the help of division property, we can search integral distinguishes for black ciphers. Firstly, we need to construct an input set with division property dk0, and then we propagate the initial division property around to get dkR. At last, we try to extract some useful integral property from dkR. So in order to use division property, we need to know the propagation rules. Next, we show some propagation rules for division property. For copy operation, the division property propagation is just to decompose the key value into all possible combinations. For XOR operation, the division property propagation is just to add the two coordinates of the input division property. For AND operation, the division property is to try to find the maximum value of the input division property. Now, the division property is defined and computed on f2n to the power of m. If n equals to 1, this is the bit-based division property. So bit-based division property treats each bit independently, so it can describe much more detailed division property, and it can find longer distinguishes and better results. However, bit-based division property need much more computations. At FSE 2016, bit-based division property can only apply to Simon 32 and CMAG 32. So in the following of this talk, we focus on how to compute bit-based division property efficiently. The overall strategy here is to use mixed integer linear programming method to characterize the division property propagation. MyROP problem tries to find the minimum or maximum value of an object function on some linear constraints. In this model, m is a constant matrix, a is a constant vector. A part of all the variables in x are restricted in integers. So in order to complete this conversion, we need to adjust two issues. The first one is to describe the division property propagation by linear inequalities. The second one is to convert a search problem to estimate the minimum value of the object function. To facilitate this conversion, we present a new launching here. Assume the input set to the block cipher has initial division property decay and the denoted division property after I run the encryption by decay. So we have this chain of division property propagations. For any k0, k1 to kr belongs to the product space of big k0 to big kr. If ki minus 1 can propagate to ki for all i, then we call k0 to kr and I run the division trill. So based on the definition of division trill, we can see that the set of the last vectors of all r-round division trills, which starts with k, is equal to kr. So now, if I input a division property, we do not need to compute k0, k1, k2 step by step. We only need to find all the division trills and check the last vectors of the division trill. But still, we don't know what kind of property we should check for the last vectors. So this proposition gives us sufficient and unnecessary condition of a set to have no integral property. Assume x is a set with the division property decay, then x does not have integral property if and only if k contains all the n-unit vectors. So in this case, give initial division property decay and round number r. There doesn't exist r-round distinguisher if and only if there exist n-division trills, which start with the initial division property k and ends up with the n-unit vectors. So now, the problem is quite clear. We just need to find the n-division trills. Next, we can proceed to the first issue. Describe the division propagation by linear inequalities. We will adjust these issues by modeling some basic operations usually in the block cycle by linear inequalities. The first one is the copy operation. This is the general propagation rules for division property. And for bit-based situation n equals to 1, based on this propagation rule, we can find three division trills for copy operation. And then, if a to b0, b1 is a division trail of copy operation, this equality is sufficient to describe these propagations because all the feasible solutions of this equality are all the three division trills of copy operation. So similarly, for XOR operation, this is the general propagation rule. And for bit-based situation, n equals to 1. For this case, we can compute three division trails for XOR operation. For this particular situation, k0 and k1 equals to 1. This propagation we are both. Because in this case, k0 plus k1 equals to 2, which is greater than 1. Since we considered bit-based division property here, so this division trail is invalid. Next, if we denote a0, a1 to b, a division trail of XOR operation, this equality is sufficient to describe these propagations. Now, for under operation, this is the general rule. And this is the bit-based situation. So we can compute four division trails for under operation. And we can compute three inequalities to describe the propagation. We can check that all the feasible solutions of these three inequalities are the four division trails for under operation. Next, we show how to model S-box. We take present S-box scale as an example. Assume this is the input division property of S-box. And we calculate the algebraic normal formula of present S-box. So from this input division property, we know that only the sum of these two monomials are unknown. But we can observe y0, y2, these two Boolean functions does not contain these two monomials. So the sum of y0 and y2 are 0. Moreover, we can compute y0 times y2. And we found y0 times y2 does not contain these two monomials. So the sum of y0 times y2 is also 0. Based on these observations, the output division property should be d0010 and 10000. So follow this similar idea. We present a generalized algorithm to compute the division choice of any S-box. The input to the algorithm is the input division property of n-bit S-box and k equals to kn minus 1 to k0. And the output is a subset of all n-dimensional binary vectors such that the output division property is dk. So firstly, we initialize as bar as all the vectors greater than or equal to k. And according to the definition of division property, fx denotes world unknown monomials. So for all u belongs to f2 to the power of n, we compute pi uy. And check if these Boolean functions contains any monomial of fx. If so, the sum of pi uy is unknown. And in this situation, we add u to k bar. At last, we run a size-reduced procedure on k bar to return k as the output. So based on this algorithm, we can compute the division choice for present S-box. These are the 47 division choice we found for present S-box. This entry in macro is red. The two division choice we computed in the example. So now for any n-bit S-box, we can compute all the division choice by the algorithm. And then we treat the division choice as two n-dimensional vectors. At last, according to Sun's idea, we can compute a set of linear inequalities based on the help of the stage software. And all the feasible solutions are all the division choice. So these are the 11 inequalities we found for present S-box. In this inequality, A3, A2, A1, A0, denote the input division property. And the B3, B2, B1, B0 is the output division property. So now for any block cypher based on copy, XOR, and S-box operations, we can construct a linear inequality system to describe the division property propagation. But still, we don't know the division property of each round. We don't know K0, K1, because this linear inequality doesn't contain any information of the input division property. So if this is an R round the division trail and let K equals to Km minus one to K0, we should add A0i equals to Ki for all i into the model. Now the input division property has been added into the model. So we know K0. And then according to the propagation rules, we know Ki, K1, K2, Kr. That's why we have solved the first issues. Now we can proceed to the second issue, convert the search program to estimate the minimum value of the objective function. And we know that if Ki contains all the in-unit vectors, R round the integral distinguisher doesn't exist. So if this is an R round the division trail, we can set the sum of the coordinates of the last vectors as the objective function. And we try to find the minimum value of this objective function. If the minimum value of this objective function equals to one, then we have found an in-unit vector. So now for any block cipher, given an input division property, we first we can construct a set of linear inequalities to describe the division property propagations for the input division property. And then we set the sum of the coordinates of the last vector as the objective function. Combine this set of linear inequality and the objective function, we can get a minor P model. And this model will be the input of the search algorithm. And the output of the search algorithm is set S. And this set will indicate the balanced bit positions. Firstly, we initialize S as all the possible bit positions. And then we try to repeat this procedure N times. N is the block size of the block cipher. And for each time we check if M has feasible solutions. If so, we optimize this model and try to get the objective value. If the objective value equals to one, we have found a unit vector and we let P denote the bit position take a value one in the objective function. In this case, P is an unbalanced bit position. So we need to exclude P from S and remove the unit vector from M. And we try to optimize this model again. So if this procedure stops, we will get a set S as the output. If this set is empty, then R-round integrated distinguisher doesn't exist. If this set is long empty, then we have found some balanced bit positions for R-round encryption. This table shows some applications of this search algorithm. We can find that we can find better result for Simon and C-max block ciphers except for Simon 32 and C-max 32. We can also find a better result for present and rectangle block ciphers. For the last two block ciphers, we find the same result as the previous best result. The more important that is this column. This column shows the execution time of this search algorithm. And among these ciphers, Simon 128 took the most time, but it's still less than an hour on a personal desktop. So this algorithm is quite efficient and practical. Okay, those are some reference. Thank you. Any question or comment? We have a long time time to discuss. Can you please go to the slide where you showed the objective function? Here. So you're trying to minimize, again, what are you trying to minimize? We try to find the minimum value of this expression, the sum of the coordinates of the last vector of the division trail. Question or comment? Let's talk speaker again.


This week on the anxious truth, we're going to do something a little bit different I have a special guest on and we're going to talk about the topic of spirituality and recovery, which I've never done before So let's get going Hello everybody, welcome back to the anxious truth. This is podcast episode number 212 212 recorded in May of 2022 if you are new to the podcast I am Drew Lynn Salada creator and host of the anxious truth This is the podcast where we talk about all things anxiety anxiety disorders and recovery So if you're struggling with things like panic disorder or agoraphobia, then this is the place for you Welcome, if you are a returning listener or viewer on YouTube welcome back. I'm glad you're here this week We are joined by a special guest my friend Josh Fletcher Psychotherapist from the UK anxiety Josh on Instagram and everywhere else on the internet Josh and I usually get together and talk about very mechanical technical Exposure-y type stuff when it comes to recovery, but today we decided we wanted to do something a little different We're gonna address the topic of spirituality in recovery Spirituality faith what they are what they aren't how you can use them. It was a really good discussion I think you're gonna enjoy it. So hang on for that But before we get to Josh, I just want to remind you that the anxious truth is more than just this podcast episode There's a ton of more stuff There are three really good books on anxiety and anxiety recovery that I've written that appear to be helping a lot of people There is my morning newsletter email newsletter and podcast called the anxious morning There are 200 and somewhat other podcast episodes and there's all my social media stuff All of that you can find at the anxious truth calm It's all there and again if you are enjoying my work And I'm helping you in some way and you want to find a way to help keep it free of ads and sponsorships All the ways to support this work can be found at the anxious truth comm slash support So go check that out never required always appreciated I appreciate all of you guys and all of your support and the time that you spend with me So let's get going with the interview with Josh. It was really good I hope you're gonna like it as much as I like doing it and I will come back at the end to wrap it up And give you all the links and all the details Let's go All right, I told you Josh Fletcher was here here. He is right next to me right next right next to me How you doing buddy? I'm doing well. Thanks.  So now I'm gonna purposely provide the dullest three minutes that you've ever had So yeah, and I was about to reveal that the one secret to overcome anxiety as well But I spy I'm just not gonna do that now See I blew it Josh was gonna solve everyone's problems in one fell swoop, and I forgot to hit the record button that happens Obviously, I'm joking Anyway, Josh is here even though he is dealing with COVID and I appreciate you taking the time and I'm glad you're You're hanging in there with that Yeah, no, I just I'm just the only thing that's getting me through is my sense of altruism selflessness and Outstanding modesty, so yeah, yeah Yeah, the funniest thing I heard from you was like, well, I'm doing okay Just that I've been reminded of my though my lack of immortality Damaging to Josh's ego to see the other moment. I was scared this morning. I woke up really like quite unwell I was really scared and panicky. I was like, oh God Few hours later, I was like, I'm fine again. There we go. He'll be all right It's a roller coaster, but I'm glad you're okay upright enough and taking the time today. Appreciate it So normally when Josh and I are on camera together or have mics queued up together it's really technical and dry and Exposure II and willful tolerance II today is not so much We're gonna talk about spirituality and all its meanings and amorphous ideas and opinions and gut feelings Which is something we don't normally go into together, which is great But I'm excited to do that because I never get to do that So we're talking about the role of spirituality and recovery and anxiety and how it all relates and what it might mean to each of us Which is probably different for every human being walking the planet in some nuanced way. So what would you call spirituality Josh? What do you think it is? spirituality is a very vague Broad concept and it's quite vague and it's specific to each individual its origins are from Religion It's you can have very secular spirituality Catholic spirituality, but all forms of spirituality across all religious beliefs But it's not necessarily exclusive to religion. There's a huge Modern movement of kind of atheist spirituality And kind of nature spirituality, whatever It involves the recognition of a feeling or a sense of belief that there's something greater than myself Believe it or not something more to be human than sensory experience that the greater Hole of which we are part of is kind of either divine or cosmic in nature depending on your belief. I Often have sprinklings of spirituality in my life, particularly when I was overcoming anxiety disorders And it's important to understand the differences between utilizing spirituality whether you're Whether it derives from your religion or whatever belief system that you have in your life If you you can use kind of spirituality if you choose to it's not essential, but if you choose to To help give you a push to overcoming Horrible sticky disorder anxiety and I'll share some examples with you Through this episode, hopefully. Yeah, yeah, I'm curious to see how it kind of fit in with you I agree with you on that definition I think it has to do with more than anything else connecting with something that is bigger than us and what that is Up to everybody I think Yeah, yeah, for me It's always interesting because and this took me a long time in my life to kind of figure reach this conclusion that spirituality and faith Could be two completely different things like there for some people They are completely linked and they are one and the same you can't take them apart and for others They have nothing to do with each other and I feel like I kind of fall into that category but the belief that there is there is something greater that we can't necessarily see or understand or Even maybe interact with who knows but it's there Yeah, and when you look at it from from from an anxiety disorder perspective, this is all I'm going to look at I mean, we don't want to we're not going to get into Sophocles versus St. Peter in a in a in a rap battle about of no, what we're going to look at is How it applies to anxiety source and this is just for me learning from my clients and stuff So people come into my practice people of faith People that use grief spiritual things like for me spirituality is something anything. It's kind of metaphysical Something that doesn't make rational sense, but helps you Get over the line You know, so for me spirituality was drawing upon grief. I am not particularly religious But during times when I was struggling with anxiety and struggling to draw upon Some strength and courage to do the things that scare me sometimes me I alone wasn't enough I felt hmm, you know, what what what can it take me today to get out and do something and it would be things like You know do it for your loved ones around here.  I'm stood there I'm scared and I think of family members that aren't here physically. Mm-hmm. And yet for somehow Metaphysically it gave me the encouragement to do it. Yeah, I don't believe that they were stood there really I'm not necessarily, but there was something that I drew upon from the the spiritual realm that helped me do it and If that isn't spirituality, I don't know what is I mean And I love that and and they dragged me out of some nasty nasty places sometimes You know the good the thing that I love is when you said it doesn't it doesn't make sense or it's not empirical But it doesn't have to that's the beauty part of this I think it doesn't have to make sense nobody has to agree with you nobody has to believe you nobody you can't Don't have to prove it. There's no data. It doesn't matter. It's just whatever it means to you in that moment and and there that can be a source of strength or motivation or encouragement or You know when and look we all struggle we have those really hard days when it feels like it's just not getting any better And you don't want to do this anymore Sometimes those those spiritual things those things that don't make any sense whatsoever except in your gut or in your heart It can be important factors And I think they are they were for me in much the same way I would say we we have a it sounds like we have a very similar experience. Yeah, yeah, definitely I mean I would I would argue it's spiritual to help your future self Mmm, I'm not doing this for me. Maybe I don't like myself at the moment, but I'll help out my future self. Yeah, you know it's spiritual to If you are a faith is to actually, you know what as as long as I'm asking for help in a spiritual way Help for me to do the scary thing then that's perfectly fine When you're asking and delving into kind of spirituality and religion to help you take away the scariness Then it you go into compulsion territory and I work a lot with Clients like that who bring faith here and it's like well You know from a psycho education point of view that's absolutely fine To do that to help pray and stuff Pray for courage because you need to do it and I think you can utilize spirituality in that way And it can help you through it. Honestly, it's you know, it's it's fascinating Basically, this is because I'm really dry and boring, but like you can use spirituality as a tool You know, here he goes again talking about No, that's not true. I mean, it's not boring in any way it might be dry, but it's certainly not boring For me it was a huge tool and I had a oh, he said huge tool And we are here for I think for me and I had such issues with those sticky intrusive thoughts about death and existence and annihilation and all It was those I was really crippled by that for a very long time and I searched desperately I did that thing where I was searching for certainty in a thing that we can't find certain We have an entire department working on that since we became sentient and we haven't figured it out yet It's called philosophy. So what made me think I was gonna do it, but I did find Meaning in an explanation that sort of sounds like group consciousness I don't want to go into the details because it's not up to anybody to care what I think or need to care What they think but and that helped me because it brought me to the idea that like, oh, no, this is my job This is my responsibility to live this the best way I possibly can today and that might suck but this is my responsibility as part of that sort of collective if we're all part of this Yeah, it really helped me in a big way to this day. I still find some comfort in that I don't know if I'm a hundred percent aligned with it from a belief standpoint, but at the moment It was a tremendous source of not conning. I think but but strength. This is my job This is I have to this is not why just because so let me just Because that's it. So I have to do what I think we're very similar in that fact that we you and many people will be where it's okay to use a Spiritual element for when you are feeling vulnerable to give you the courage It's really important though to realize and you know me I always bang on about this and said it in previous episodes with you What if it's on my podcast or yours? It's you you got to make sure that you are getting the credit You know and it's so important and You know it You went to these these things You've you've went found this group you delved into that and it gave you the courage and strength to define your own Path and then you did it Whereas there's a big difference between going somewhere and asking them to take away the pain Give me the the certainty give give me all the reassurance I need tell me everything's going to be okay a hundred percent for the rest of my life No anxiety disorders love that And I know no I've been there and as someone who you know I grew up in a very religious family Well one half of it was And it's been like no we don't we don't need to kind of You need to be the one that's doing it and it's lovely and you can use Things to help you but ultimately you have to be getting the credit for it So if that's any religion things like that I also want to talk about like If you're looking at the broad spectrum of spirituality, there's lots of spirituality and like nature and things like that And for all the like the nerds and the empiricists, you know you've got the Look at the data of people like you know walking forest bathing Walking in nature to walk and talk therapy stuff like that being in and around nature the data shows you That it's just profoundly brilliant for your brain and your happiness and whatever How I don't know some people interpret that as well as a tree and it's giving me oxygen some people interpret that as You know, there's something quite spiritual about being in in a forest being something that's older than me But living on a planet without in the way it's supposed to be but yeah It doesn't matter why or why yes, just enjoy the benefit. Yeah, what's real like trees? Huge tree phantom if I'm a fan But it doesn't matter like yeah, yeah, there is I may get that there certainly there's a lot of data that shows You know that that is tremendously helpful, but who cares why? Yeah, absolutely. Maybe it's spiritual. Maybe there's a maybe there's some divine intervention there Who knows maybe just a primal connection to things older than us who cares? Yeah, if you're hugging a tree and you could feel it pulsing through you and it's making you happy You had no judgment from me. That's great. Yeah, you get envy Nothing but envy It'll be a better day today Now I'm with you on that and they who gets the credit is so important so important Because I think and I wrote about that when I was writing the anxious truth because then my community It's always I look I first of all everybody doesn't think I have such tremendous respect for all these people because We sometimes have that conversation in my community and it's always so respectful and so kind and so compassionate and so Just an open exchange of ideas. It never devolves into you have to believe what I said And I just huge kudos to everybody for being such good human beings but I felt like I had to address it and that To me in my view of a faith-based view in my experience It was like well if if there is a creator or some divine being that that you believe is there and that helps you That's great, but it he she them gave me these tools and I felt It's my part of my responsibilities to use those tools not to just ask that power to take it away But I do understand that some people do feel that the right way to do this is to simply hand it to something bigger But yeah, there's a tough one for people like you and me though. I think Yeah, absolutely Just hand it off and it will that will get better. Yeah, a lot of people there's blocks to people Accepting that it was them that did it like you're allowed. There's no it's not being selfish or Overly so I congratulatory to to say that you did it. It's essential. It's mandatory in in my and Drew's opinion Yeah, if you want to recover, you it's got to be you I hear a lot of you must hear this lot.  I went to the movie theater and then I drove 30 miles to see my aunt Thank God. I got there and and I'd usually reframed that would like well if you're really religious, you know I thank God for giving you the tools exactly for you deciding to go there Yeah, and it's like it just subtle reframes like that And if you're someone who wants to pass The the credit onto someone else or who wants to give it or something else Just be selective with what you are giving because you deserve credit too. It's you.  I Every anything can get credit indirectly family friends Faith religion support network Much needed medication, you know things can get indirect credit, but ultimately it's built around you and Just make sure you're doing that, you know Your spirituality is a tool for that for you to access it, but it was always you It's important. I think not you not to delve too deep into this because it can get a little bit sticky But you know, I don't think that that's a denial of one's faith I think it's an affirmation to be honest with you And I think there are many of people I think listening to us today that struggle with that And I know because they've been open and really brave about talking about it in some instances That the idea that that I can't just give it away and it's not getting better. I Have to do something. It feels like a betrayal of the faith and so Absolutely, and I get that and sometimes they're told it to be trail of the faith So I think if nothing else to to acknowledge in this conversation that sometimes That spirituality and faith if they're one of the same for some people can create a crisis in recovery It's and it's a real crisis. Yeah. Yeah, I hear that a lot and then obviously you include people with OCD We're religious group elasticity as a theme. Yeah, but if you're guilty and stuff like that I mean if you're if you're one of them listening now, you know, don't get me wrong We we see you so good, you know, you're not a bad person all these things. Yeah, it's about It's about getting your ducks in order You know, you're not getting rid of them. Just get it in order and see what's actually happening as opposed to you know, I just By me not giving a hundred percent of everything to something else. I'm being a bad person. No You're you're allowed to have your autonomy and again, we won't get too much into it But if you look at the basis of a lot of religion, it's about celebrating your autonomy Whilst living in a in a culture of appreciation and praise. That's a lot of kind of religious structure. You're allowed your autonomy Yeah, I think it's a big deal and for nothing else than to acknowledge that if you're if you're a little bit in that crisis and feeling between a rock and a hard place because of maybe what you believe and and Why that's not working for you then at least hey, look, we get it There's a place at the table here for you to work that through however way you have to do that It's the best we could say about that. Hmm. Yeah, yeah Yeah, but anyway, so I'm sorry I kind of derail that just a little bit. Sorry, you want to you want to crack at theology didn't you want to be spicy? You know what never here to take a swipe at anybody's faith, I guess I don't get to do that No, no, absolutely. No, and I've seen it I think the important thing is it doesn't matter what your faith is or whatever your spiritual belief is You can recover Just make sure it becomes an aid not a hindrance You know, you don't want to compulsively pray in the middle of a panic attack Because then you don't get the credit for tolerating the panic attack if you would need to pray pray before and pray after You know pray for the help that it was the courage that you had to do that if you're part of some kind of alternative Spirituality, you know and you want to thank the earth. That's great do it before and after But if you're going through intense anxiety, it's got to be you but that does it and I'll just do what I did like I remember like I Had to go into a hospital once terrified And I just kind of spoke to my My deceased family members and I was like which is ironic considering I was walking to a hospital and They were just yeah, I just I just spoke out loud and just Wanted to believe that they were there with me and that just that wanting that faith Was enough to kind of get me into the hospital. Don't get me wrong. I still believed it was me that went into the hospital but but There was just that element that was there. Yeah, you know, and there's just you do you do see these little things And it's about it's about your interpretation as well Like I have had weird things happen to me. It's weird spiritual stuff that just doesn't have an explanation and I'm like Cool, I'm not even gonna question. I'm just gonna Yeah, take it take it around why not take it and run with it exactly and I'm just think it was important that we spoke We spoke about this drew because you know, a lot of people do have that kind of spiritual element Yes, we're not I don't think we'll be writing a book on it anytime soon But it was nice just to have two people who can be very cut and dry with the approach to just talk about this topic Let's take a couple of minutes. It may be what you know what?  So hang on There is no other Mac he's having a spiritual experience it's helping me by trying to set up with voice assist like no no no But anyway, one of the things that I do want to touch on a little bit is and it's interesting because faith-based spirituality can get a little bit Dicey we talked about that But that's just faith and we've all said you don't have to prove it and nobody has to believe you nobody has to agree with you Which is great. There's another side of spirituality that I think you've hinted at a little bit like nature-based Cosmically based and sometimes that could get dicey because sometimes that camp does claim that it is real And there is science and if you vibrate at the proper frequency and look quantum mechanics says that if you do it this way And that can get that's another thing that can create problems for people in our community I think that's a form of spirituality. I think and that form of spirituality. I'll just say it fuck it We're in that mode now It gets it can get super toxic more so than almost any church because of the oh no, this is science This is truth Like quantum I read about quantum mechanics in Huff Po and it said that we vibrate and so if you vibrate at the right frequency You will overcome your anxiety Yeah, you've got to you got to be careful when people when there's a Red flags always wave when there's either a fatalistic tone to these things or an accusatory term So some people it'd be like you're anxious because you're not vibrating at the right frequency or whatever or Mercury is in retrograde. Well, if you want to be that kind of spiritual to that's okay, but when it becomes accusatory And when it implies that it's something that you're not doing On a way that hasn't really kind of there is no science or Then there's a huge red flag and you've got to take a step back and kind of look at that critically There's a lot of people out there that will use that to exploit you They'll get on their soapbox and say things like, you know Use things that will resonate with you and then and then talk absolute Shite and get you to think that you know to start to subscribe to what they're they're saying. Yeah very prescriptive Yeah, it is and a lot of it relies on you just Assuming that the teacher is right. There's no there's no there's nothing really to back it up You know when a lot of these kind of toxic communities don't get me wrong I know people that that use it again in here. I've seen it before I've no people to use it to an advantage No, here's just the slaughter it but it depends on your Your relationship with it so for example I had a client here He's like, you know what I waited to this day because I knew that this day my forgive me This is probably insulting if they're there this be no the You know everything was aligned Everything in the car in my astrology was aligned and today was the day that I felt confident to go and challenge Magrophobia and they did They used it as a stepping stone and you know, I wasn't sitting there going, you know what?  You're talking nonsense Yeah, and I've seen that and again, I don't want to skewer it because it's true It can also be a very useful framework like anything else. I think that's fine But yeah, it can get a little bit nasty too when you get in that's I've had people who will literally argue with me No, no, no, it's the mercury retrograde and I don't understand any of it I will completely 100% own that and I'm clueless as to what the logic behind that would be but No, that you don't understand the reason why I'm having panic attacks is because of that and that seems But but no, that's that gives away all of your influence and all of your power.   You're not it's not why it's maybe Actually, no, I'll tell that back. Maybe you could be maybe your belief Yeah, that's your fear of fear. Yeah might trigger him because someone has suggested to you Yeah, and so the next time Mercury is in retrograde or another thing. I know it's very rudimentary and again, I apologize for anyone who's into that. I don't read about read about it a lot, but Yeah, that could trigger panic, but the very suggestion and the association you have with it triggers panic But it's not nothing to do with where The actual location of a celestial body. Yes, absolutely But again, it could be useful tool and I've seen it be same as you I've seen people use it to great success It's yeah to give them a little bit. This is the time. This is the time I changed my life. Yeah. Yeah I and this is the time we wait for yeah, I've seen that happen and I applaud. I think it's fantastic And I think in the end I've seen people You know do smudging and burn sage and do all of those things and I might not do those But if that brings you a sense of if it puts you on a firm base that you can jump off from what's smudging You never heard smudging. I just learned that that's you long ago smudging is I think it's it might be the sage burning It's called smudging when you just you circulate the the sage smoke or the herb smoke. All right, again I would only my ignorance. I don't understand the purpose of it necessarily But I know plenty of people who engage in that sort of thing and it does it gives them a little bit of a more stable base To jump off from and it works. So why would I do that then and a shout as well? The person's pitch out to people do like reiki and stuff like that my mum does reiki and things like that And you know, it's really nice about it. She likes she wants to practice her reiki on me because she's she's training it and stuff I necessarily believe in it, but I'll go around and do it. You know what? What's really nice is that it's a nice hour with my mum. I feel super relaxed I'm not thinking about work and actually that's quite spiritual in itself It's just really nice to sit there close to my mum and You know, she feels a connection to me. I'm lying there snoring. It's really lovely Um, and even I think that that's lovely. I think that's really lovely. I just think Yeah, uh, yeah, I'm not here to knock it at all Side effects and you know, who cares what the benefit is but in the end of this benefit go for it So I think you know the takeaway hopefully from all of this is spirituality doesn't have to be proven It doesn't have to be argued. It doesn't have to be you don't have to show me data You know, if you find things that help you get to the point where you can take the action that you need to take Because you've been given the the opportunity and the skills and the the strength and the courage to do that then been great and just And you know, and I'll give josh the last word here as a guest, but just don't let it become The the explanation for why your life is changing Because then then you give away all the because then if if something changes down the road and it's outside of your control It'll come I have a relapse to happen and we can come back If it was you that never got the credit for it, right, right So just use it to give yourself that that's the base of strength courage motivation, whatever And I'm yeah, yeah, great. Yeah, absolutely. Um, and I'll share with one of my weird spiritual moments with you and um, I remember Not so long after after grief and I was struggling with the agriphobia and panic and stuff like that And I got into an aeroplane flight to Greece and as it got I was really scared and as it got, you know Passed through the clouds and those and we were flying. I looked out through the clouds And this is sound really lame and weird and it always does but honestly from my perspective it was amazing I looked through the clouds and I could I honestly thought I could see some of my Relatives that passed away in the clouds sounds really lame I know but I saw it. I didn't even question it It probably helped that I had about two or three whiskies before I got on the plane But it doesn't matter. I'm not gonna question it. It was a beautiful moment Uh, and then a really nice holiday Just things like that. I just you know, I can't I never I never knock it, you know I can't explain it either. I'm gonna get mocked for that, aren't I? No, yes, you're not. There's anxiety Josh is a little cloud family. Oh, bless you You know what? I would never mock that So I'll give you my own little 30 second when my grandma passed away my mom my mother's mom And I was very close to my my mother's parents and when my grandma passed away It was just it was three of us in the house She passed away in Florida We're up in New York and there was only three of us in the house and I woke up the next morning And I was alone in the bedroom And no one until they put me in a box will tell me otherwise I could smell the the the smell of the sundae sauce being from a big Italian American family That's what I grew up with on a sundae That smell was in my house. It was in the house. I laid there. I made sure I actually smelled it I just laid in it for a few minutes. I got up. I got out of bed I walked around the bedroom And and the smell was still there as powerful as ever I opened the bedroom door expect I get seen to the kitchen expecting to see maybe Because my mother was up from the bar at the time. Maybe she was In the kitchen And the minute I opened the door there was no one in the kitchen. The rest of the house was asleep and it was gone Oh, wow In the worst moments that when I was struggling really hard and doing my exposure work I would smell the smell of my grandfather's cigarettes.  Thank you for sharing that with me. Well, thank you for sharing your cloud family with me and I think And and if and if you've only just tuned in The key to anxiety recovery is sundae sauce and find your dead relatives in the clouds above and you're good to go I will All right, my friend. Thank you so much for taking the time. Where can everybody find you? I'm going to give everybody this is episode 212 So you can go to the anxious truth.com slash 212 to get all the links, but where where can people That's incredible Anxiety josh. There you go. You can find me anxiety josh. Yeah. Yeah, just google anxiety josh. He will come up. I've done it Yeah spamming your inbox Anyway, my friend, thank you so much. I'll be back in a second into the studio Which is this very desk right here. We'll do the wrap up, but and we'll have josh on again And I will say this anybody listening that wants to participate in this discussion I don't know theology student clergy member somebody who has something to add I'll I'll come on with you. I don't know if josh wants to join that one day, but That would be great. Let's see. Sounds good Okay, we are back just as I promised here in the studio, which is the exact same place that I was three minutes ago Talked to my buddy josh. Uh, anyway, I hope you guys enjoyed that interview I really it really wasn't so much of an interview was just sort of an informal discussion Which is something that I don't do a lot. Most of my stuff is a little bit more technical a little more dry and mechanical so I really enjoy it exploring that topic and we'll do that a little bit more and again open invite for anybody who has A little bit more to add on this reach out. Um, if you're involved in the faith community or you are student of theology or philosophy or you want to talk about some of that stuff Maybe we'll just do another episode to follow up josh is willing to come on and we'll all talk about it informally and Exchange ideas. I think it's great. I love having discussions like that. So if you want to find more about josh You can find him. He's anxiety josh on instagram His website is the school of anxiety Just go to the anxious truth.com slash two one two and I will have all of josh's links in the show notes for this episode And that is it for episode two twelve. You know, it's over because music That as always is afterglow by ben drake You can find ben and his music at ben drake music.com Go check him out because he's a great musician and just a good guy tell me said hello if you do And that's it for episode two twelve of the anxious truth. Thank you for coming by and spending time with me I'm going to ask you what I ask you every week Which is if you're listening on itunes apple spotify any place where you can rate and review the podcast Take a minute. Leave a five star review even better Take an extra minute and write a short little review of the podcast so that Everybody else can find the podcast and that's why we do this to as reach as many people as we can That's it. I am out. I will be back next week as always. I don't know what I'm going to talk about but I will be here So remember this is the way


The provided HTML code represents a web page for a fuzzy logic waveform detector, an interactive web application demonstrating the use of fuzzy logic in identifying different waveform shapes on the various noise levels. The web page includes meta tags and title, description and title for search engines and social media sharing, along with character set and viewport settings for responsive design. Starsheets, external CSS files for styling, including a flask-specific syntax for linking starsheets. JavaScript sources, external scripts including plot leaf for graphing functionality and the delayed script loading fads. Header section, contains a navigation bar with a logo and menu items, along with a unique menu toggle mechanism for mobile views. Control panels for selecting input waveforms and adjusting noise amplitude. Sections for displaying output wave details and statistical data. Graph containers for visualizing input and output waveforms. Informational content, detailed descriptions and insights about the application, its functionality, and the concept of fuzzy logic, particularly in signal processing. Technical details, mentions the use of HTML, CSS, JavaScript, SKFuzzyLibrary, plot leaf and flask. Closing note, a thank you note and invitation for feedback. Dynamic script loading, a script for loading Google AdSense is dynamically appended after a delay. The page is structured to be interactive and educational, focusing on the application of fuzzy logic in waveform detection and analysis. The provided JavaScript code is designed to work with the HTML page of the fuzzy logic waveform detector. It is executed when the DOM content is fully loaded. Here's an overview of its functionality. Element selection, it selects various DOM elements like drop-down for input wave selection, slider for noise amplitude, and spans for displaying detection error and unknown percentage. It also selects a div for the input graph. Update output, data, updates the text of elements to show the output wave, detection error, and unknown percentage based on the data received. Update input graph, signal, uses plot leaf to plot the input waveform graph using the signal data received. Retrieves values from the input wave drop-down and noise amplitude slider. Sends a post request to the server endpoint, analyze with the input wave and noise amplitude as JSON data. Upon receiving the response, it updates the output information and input graph using the received data. Handles any errors that occur during the fetch operation. Adds a vendlessness to the input wave selection and noise amplitude slider. Whenever there's a change or input event, the analyze waveform function is triggered. Initial analysis invocation, calls analyze waveform to perform an initial analysis when the page loads. This script essentially makes the web page interactive, allowing users to select different waveforms and noise levels, and then see the analysis results and graph updated in real time based on their selections. This Python script uses Flask to create a web server for the fuzzy logic waveform detector. It defines several key components and functionalities. Flask app initialization, the Flask class is used to create an instance of a web application. The home function is mapped to the root url. It serves the index, html page. Analyze root, analyze, post method. The analyze function handles post requests for analyze url. It receives JSON data from the request, extracts the input wave and noise amplitude, and processes them. The generate underscore signal function creates a signal based on the input wave type. The add underscore noise function adds noise to this signal. The analyze underscore signal function analyzes the noisy signal using fuzzy logic. The calculate underscore detection underscore error and calculate underscore unknown underscore percentage functions compute statistical metrics. The results, including the process wave information and statistics, are returned as JSON. Generate underscore signal creates different types of waveforms based on the input string. Add underscore noise adds Gaussian noise to the signal. Analyze underscore signal analyzes the noisy signal using fuzzy logic implemented in the fuzzy underscore logic function. Fuzzy underscore logic implements the fuzzy logic system using the sk fuzzy library. It uses membership functions and fuzzy rules to classify the signal into different wave types, square, triangle, trapezoid. Calculate underscore symmetry underscore array calculates symmetry of the signal. Calculate underscore peak underscore sharpness underscore array determines the sharpness of peaks in the signal. Calculate underscore detection underscore error computes the percentage error in detection. Calculate underscore unknown underscore percentage calculates the percentage of waves classified as unknown. The if underscore underscore name underscore underscore equals equals underscore underscore main underscore underscore block checks if the script is being run directly, not imported. If true, it starts the flask app with dbyg equals true for development purposes. This script is a back-end part of the Fuzzy Logic Waveform Detector web application. It handles data processing and analysis and communicates with the front-end, html, JavaScript, to provide interactive waveform detection functionality. The output in the Fuzzy underscore logic function is determined by the Fuzz, the Fuzz method, which computes the centroid of the aggregated membership functions. The final output waveform type, square, triangle, or trapezoid, is selected based on where this centroid value falls within certain ranges. If output less than one-third, the function returns, square. If output less than two-thirds, it returns, triangle. Otherwise, it returns, trapezoid. If you're always getting, square, as the output, it suggests that the centroid, output, is consistently falling below one-third. This could be due to several reasons. Input data characteristics, the characteristics of the input data might be said that they consistently lead to a low centroid value. Membership function definitions, the way membership functions are defined, mf underscore symmetry underscore low, mf underscore symmetry underscore mid, mf underscore symmetry underscore high, etc., might be influencing the centroid calculation. If these functions are not properly calibrated or if they don't accurately represent the characteristics of the different wave types, it might skew the results towards one particular category.  Signal processing, the methods calculate underscore symmetry underscore array and calculate underscore peak underscore sharpness underscore array might be processing the signal in a way that favors the conditions for a square classification. To diagnose this issue, you can check the values of symmetry and peak underscore sharpness arrays, as well as the outputs of membership functions and rules, to see if they're lying with your expectations. You can test with different input signals and noise levels to see if the issue persists across various scenarios. Debug the fuzzy underscore logic function by printing out intermediary values like the aggregated fuzzy set and the resulting centroid to understand how the final output is being computed. Graphically reviewing fuzzy parameters involves visualizing the membership functions, rules, and the resultant fuzzy sets. This can be done using libraries like matploblib in python. Here's a step-by-step guide to visualize these components in the context of your fuzzy logic waveform detector. Install matploblib. If you haven't already, you'll need to install the matploblib library. It can be installed via pip, copycode pip install matploblib. Define membership functions. Your script already defines membership functions. You can plot these functions to see their shape and range. Plot membership functions. Use matploblib to plot these functions. For each membership function, plot the universe x-axis against the membership value y-axis. Visualize rules. Rules are usually combinations of membership functions. You can visualize the result of these combinations. Show aggregated output. The aggregated output fuzzy set can also be plotted to see the combined effect of all rules. Plot defuzzified result. Finally, you can plot the centroid calculation on the aggregated output to see where the defuzzified result lands. Here is an example code snippet to illustrate how you could plot one of your membership functions. This code will plot the low-symmetry membership function. You would repeat similar steps for other membership functions, the rules, and the aggregated output. This graphical representation will help you better understand and debug your fuzzy logic system, giving insights into how different inputs affect the output.  For each fuzzy set, like symmetry and peak sharpness, plot all the corresponding membership functions. Plot the result of the fuzzy rules. These are combinations, like fmin or fmax, of the membership functions. Plot the aggregated output from all the rules. Finally, indicate the defuzzified result, centroid, on the aggregated output plot. Plot the result of the fuzzy rules. These are combinations, like fmin or fmax, of the membership functions.  One, plotting all membership functions, for each fuzzy set, like symmetry and peak sharpness, plot all the corresponding membership functions. Symmetry membership functions. To continue with the graphical representation, especially within the context of the fuzzy underscore logic function, you would integrate the plotting directly into your fuzzy logic processing. This allows you to visualize how the membership functions, rules, and aggregated output are working for each specific instance that the fuzzy underscore logic function is called. Here's how you can do this. Integrate plotting into fuzzy underscore logic function. Within the fuzzy underscore logic function, after defining membership functions and rules, you can add code to plot these elements. This way, each time fuzzy underscore logic is called, it will generate corresponding plots. Plot membership functions. Plot the membership functions for symmetry and peak sharpness. Visualize the activation of rules. Show how the rules are activated based on the input data. Display the aggregated output. Plot the aggregated output to see the combined effect of all activated rules. Plot the defuzzification process. Indicate the centroid value on the aggregated output plot to visualize the defuzzification result. Here's an example of how you can modify the fuzzy underscore logic function to include these plots. In this modification, after each step in the fuzzy logic process, corresponding plots are generated. This visual representation is immensely helpful for debugging and understanding how your fuzzy logic system behaves with different inputs. Remember that displaying these plots will be more useful during the development and testing phase. In a production environment, you might want to disable these plots or log them differently. In this modification, after each step in the fuzzy logic process, corresponding plots are generated. This visual representation is immensely helpful for debugging and understanding how your fuzzy logic system behaves with different inputs. Remember that displaying these plots will be more useful during the development and testing phase. In a production environment, you might want to disable these plots or log them differently. Fuzzy logic is a form of logic that allows for more flexible reasoning compared to traditional Boolean logic, which is strictly true or false. In fuzzy logic, truth values can be any real number between 0 and 1, representing degrees of truth. This approach is particularly useful in scenarios where the information is imprecise or uncertain, allowing for a more nuanced and realistic decision-making process. In the context of your fuzzy underscore logic function, it is returning an output based on the analysis of a noisy signal using fuzzy logic principles. Here's a breakdown of what the function is doing. Input analysis. The function receives a noisy signal as input and processes it to extract features like symmetry and peak sharpness. These features are used to evaluate the signal against defined fuzzy logic rules. Membership functions. The function defines several membership functions for different features of a signal, like low, mid, and high symmetry. Membership functions are curves that define how each point in the input space is mapped to a membership value or degree of truth between 0 and 1. Rule application. Fuzzy rules are applied to these membership values. These rules are logical statements that determine how the input features should be interpreted. The function uses the minimum, NP, FMIN, operator to combine the membership functions in these rules. Aggregation of rules. The results of these rules are then aggregated into a single fuzzy set. This is done using the maximum, NP, FMIN, operator which combines the outputs of individual rules. Defuzzification. Finally, the function uses the Fuzz. Defuzz method to perform defuzzification, converting the fuzzy result back into a single crisp output. This is typically done by finding the centroid of the aggregated fuzzy set, which represents the center of gravity or the balance point of this set. Return output. The function returns a string, square, triangle, or trapezoid, based on where the centroid value falls within predefined ranges. This output represents the classified shape of the waveform based on the fuzzy logic analysis. In essence, your fuzzy underscore logic function is using fuzzy logic to classify a waveform shape from a noisy signal, returning a value that best represents the characteristics of that waveform according to the defined fuzzy rules and membership functions. Fuzzy logic waveform detector. Welcome to fuzzy logic waveform detector, an application designed to demonstrate the capabilities of fuzzy logic in identifying various waveform shapes under different levels of noise. This tool allows users to select a waveform, adjust noise amplitude, and observe how these changes affect the detection accuracy of the system. Utilize the drop-down menus to choose the type of inward waveform you wish to analyze in the slider to simulate varying noise conditions. The application will display the identified waveform and statistical analysis, providing insights into the performance of the fuzzy logic detection algorithm. This is particularly useful for educational purposes, allowing students and professionals to experiment with signal processing concepts and understand the impact of noise on detection systems. Whether for academic learning or industry demonstration, this application serves as a valuable resource for exploring the intricacies of waveform analysis. How it works, the tool uses a fuzzy logic system to identify the inward waveform. The system consists of three inputs, the inward waveform, the noise amplitude, and the output waveform. The inward waveform is a crisp value while the noise amplitude and output waveform are fuzzy values. The system uses the inward waveform and noise amplitude to determine the output waveform. The output waveform is then compared to the inward waveform to determine the accuracy of the system. Getting started, select a waveform from the drop-down menu and adjust the noise amplitude using a slider. The application will display the identified waveform and statistical analysis, providing insights into the performance of the fuzzy logic detection algorithm. Features, interactive waveform selection, adjustable noise amplitude, real-time waveform detection, statistical analysis, key insights. Waveform detection is more accurate with lower noise amplitude. Waveform detection is more accurate with more distinct waveform shapes. Fuzzy logic. Fuzzy logic is a form of many-valued logic that deals with reasoning that is approximate rather than fixed and exact. In contrast with traditional binary logic, which uses the values of true or false, fuzzy logic uses the values of true, false and partially true. This allows for more nuanced reasoning and more accurate decision-making. Fuzzy logic is particularly useful in situations where the data is incomplete or imprecise, such as in signal processing. In biomedical data, fuzzy logic can be used to identify various waveform shapes on the different levels of noise. This is particularly useful in the field of signal processing, where it is often necessary to identify the shape of a waveform in order to determine the type of signal. For example, in electrocardiogram, ECG, data, it is often necessary to identify the shape of the waveform in order to determine the type of heartbeat. Fuzzy logic can be used to identify the shape of the waveform and determine the type of heartbeat with a high degree of accuracy. Technical details. The application is built using HTML, CSS, and JavaScript. The waveform detection system is implemented using the SK Fuzzy Fuzzy Logic Library in Python. The application uses the Plotli library to generate the graphs and the Flask library to host the application on a local server. Closing note. Thank you for using fuzzy logic waveform detector. If you have any questions or comments, please feel free to contact me using a form on the contact page. To display these plots on the front page of your web application, you need to generate the plots on the server side, convert them into images, send them to the client, Raza, and then display them on the web page. Here's a step-by-step process. Generate plots on server side. In your Flask backend, modify the fuzzy underscore logic function or any other relevant function to create and save the plots as images. You can use Matplotlib to save plots directly to a buffer. Convert plots to images. After generating a plot, instead of displaying it with PLT, show, save it to a bytes.io buffer as an image, e.g. PNG format. Encode images for web transfer. Convert the buffer content to a base 64 string. This makes it suitable for embedding directly into an HTML image tag or sending as JSON data. Send images to front end. In your Flask root, include these base 64 encoded strings in the JSON response sent back to the client. Display images on web page. In your front end JavaScript, modify the code to handle these image strings. When you receive the response from your Flask server, extract the image data and set it as the SRC attribute of an IMG tag in your HTML. Here's an example implementation in Python. If you prefer to send the plot data as JSON instead of images, you still need to convert the plots to a format that can be transmitted over HTTP and then rendered on the client side. One efficient way to do this is by converting the plots to a data URL format, base 64 encoded, and then embedding this data within JSON. Here's how to modify the process. Generate the plot in your Python code as before. Convert the plot to base 64 string as you did previously. Embed the base 64 string in your JSON response. This way, you're sending the image data as a string within your JSON structure. Fetch the data from your Flask root as you normally would. Extract the base 64 string from the JSON response. Set this string as the source for an image element in your HTML. Make sure you have an IMG tag in your HTML where you want the plot to be displayed. This method allows you to send the plot data as a part of your JSON response. The client side JavaScript then takes this data and uses it to display the image. Using PLT, savefig, buff, format equals png in this context, even though we're not transferring traditional image files, is a method to convert the plot generated by Matpoblib into a format that can be converted into a web page. Here's the reasoning behind it. Format conversion. Matpoblib creates plots in a graphical format. To incorporate these plots into a web page, they need to be converted into a web-friendly format. The png format is universally supported by web browsers and is suitable for high-quality images. Buffering. The bytes.io object acts as an in-memory buffer. When you use PLT, savefig, buff, format equals png. You're saving the plot as a png image into this buffer instead of an external file. This approach is useful for dynamically generated images that you don't need to store permanently. Base64 encoding, the contents of the buffer, which now contains the png image data, are then Base64 encoded. Base64 is a method of encoding binary data into a string format that can be easily transmitted over the internet. It's particularly useful for embedding binary data, like images, within text-based formats like JSON. Embedding in JSON, the Base64 encoded string can be included in your JSON response. This string represents the image data of your plot. Rendering on the client side. Once the client, web browser, receives this JSON response, it can decode the Base64 string back into binary format and render it as an image in the HTML document. Transferring the raw data required for plots from a Python backend to a JavaScript front-end for rendering is a viable approach. This method involves sending the numerical data points into the settings through JSON. The front-end, JavaScript, then uses this data to create the plots, typically using a JavaScript charting library like Chart, JS, Plotly, JS, or D3, JS. Here's a general outline of how to implement this. Prepare data points. Generate the necessary data points for your plots in your Python code. Create a JSON response. Package these data points into a JSON-friendly format. Fetch the data, and then age acts called to your Flask root and retrieve the JSON response. Use a charting library. Use a JavaScript library to render the plots using the received data. Include a canvas element in your HTML for the chart. Flexibility. You can modify the plot on the client side without needing to reprocess it on the server. Reduce server load. The server only needs to send raw data, not process and render images. Interactive plots. JavaScript charting libraries often allow you to create and hovering. There are several JavaScript charting libraries available. Your choice depends on your specific needs. Chart. JS, simple and easy to use, great for basic charts. Plotly. JS offers a wide range of chart types, including 3D charts, and is highly customizable. D3. JS, highly flexible and powerful, suitable for complex data visualizations, but has a steep learning curve. Each of these libraries has its own syntax process, so you'll need to refer to the respective documentation for implementation details. To include the sharpeners membership function in the plot and convert the entire plotting process into JavaScript, you'll need to follow these steps. Prepare the data. On the Python backend, calculate all the necessary values for your plots, such as the X and Y coordinates for the membership functions and any other relevant data. Create a JSON response. Structure the data in a JSON format. This should include all the data needed to recreate the plots on the client side. Send the JSON response. From your flask root, return the JSON response with the data to the front end. Write JavaScript code. On the front end, write JavaScript code that takes the JSON data and creates the plots using a charting library or custom drawing code. The JSON response from your back end, Python, might look something like this. On the front end, you would use a charting library or the HTML5 canvas API to draw the plots based on this data. Here is a solo code example of how you might do this with chart, JS. Remember to include less than canvas greater than elements in your HTML with corresponding IDs for each plot, e.g., id="symmetry chart". The charting library will use these canvas elements to draw the plots. To include the sharpener's membership function in the plot and convert the entire plotting process into JavaScript, you need to follow these steps. Prepare the data. On the Python backend, calculate all the necessary values for your plots, such as the X and Y coordinates for the membership functions and any other relevant data. Create a JSON response. Structure the data in a JSON format. This should include all the data needed to recreate the plots on the client side. Send the JSON response. From your flask root, return the JSON response with the data to the front end. Write JavaScript code. On the front end, write JavaScript code that takes the JSON data and creates the plots using a charting library or custom drawing code. The JSON response from your back end, Python, might look something like this. Python, copy code and generate underscore plot underscore data. Hash this function would normally calculate these values based on your input data return. Symmetry, X, list, range, minus 100, 101, low, fuzz, trimf, X, minus 100, minus 50, 0, for X in range. Minus 50, 0, 50, for X in range, minus 100, 101, high, fuzz, trimf, X, 0, 50, 1. On the front end, you would use a charting library or the HTML5 canvas API to draw the plots based on this data. Here is a pseudocode example of how you might do this with chart, JS. Remember to include less than canvas greater than elements in your HTML with corresponding IDs for each plot, e.g. it equals symmetry chart. The charting library will use these canvas elements to draw the plots. The HTML structure you've provided is for the fuzzy logic waveform detector web application. It already includes sections for interactive control elements like drop-down menus and sliders, placeholders for statistical information, and div containers where you can render the graphs. To display the fuzzy logic parameters, membership functions, rule activation, and aggregated output, using JavaScript, you need to modify the back end to send the necessary data to the front end and use a JavaScript library like Plotly, JS to render the graphs. Here's a simplified version of what you need to do. Back end, Flask, modify your Flask routes to send the data points for the membership functions, rule activation, and aggregated output as JSON. Front end, JavaScript, write JavaScript functions to request this data to send to the front end. Write JavaScript functions to request this data from the back end and plot it using Plotly, JS. Ensure you have Plotly, JS included in your HTML or loaded dynamically as you are doing with other scripts. HTML, adjust your div containerids to be unique and valid, and use them to target where the graphs should be displayed. Here is an example of how you might adjust the HTML and write JavaScript to use Plotly, JS for rendering the plots. In your Flask back end, you would have a route like, get fuzzy logic parameters that computes the required data and sends it back as JSON. This is a basic example to get you started. You would need to extend it to handle all the data points for the membership functions and include the logic for plotting the sharpness functions and rule activations. Also, the ins of the div elements in the HTML are updated to be more compliant with common conventions, using hyphens instead of spaces. Chat GPT. The HTML string. In your Flask back end, you have a route like, get fuzzy logic parameters that computes the required data and sends it back as JSON. This is a basic example to get you started. You would need to extend it to handle all the data points for the membership functions and include the logic for plotting the sharpness functions and rule activations. Also, the IDs of the div elements in the HTML are updated to be more compliant with common conventions, using hyphens instead of spaces. To update your Python Flask back end code to send the necessary values to the front end using JSON, you need to calculate the necessary data points for your plots based on the fuzzy logic operations. Structure these data points into a Python dictionary, which can be easily converted into JSON. Send the structured data as a JSON response to an Ajax request made by the front end. Here is a modified version of a Flask route that calculates the necessary data for the fuzzy logic parameters and returns them as a JSON response. This code assumes you have NumPy and SKFuzzy installed in your environment. It also assumes that you have the logic to calculate the real values for rule activation and aggregated output based on your fuzzy logic system, which you will replace where the random values are currently being generated. Once this Flask route is set up, your front end JavaScript code can make a get request to, get fuzzy logic parameters, receive the JSON response, and use it to plot the graphs as previously described. To update your existing Flask code to include the necessary values for the fuzzy logic plots you will need to make several additions. Specifically, you'll need to modify the Analyze route to also compute and return the data for the membership functions, rule activations, and aggregated output and response. Here's how you can update the Analyze route. With these changes, the Analyze route now returns all the necessary data for plotting the fuzzy logic parameters. The front end can then use this data to render the plots as previously described. Remember that this code assumes the rest of your Flask application and JavaScript front end does set up to handle this additional data. The front end will need to pass the fuzzy data object and use it to plot the graphs using a library like Plotly.js. Your updated fuzzy underscore logic function looks good. It now returns two things, the determined output underscore wave based on the centroid of the aggregated membership functions and the fuzzy underscore plot underscore data which is a dictionary containing all the data needed to plot the fuzzy logic parameters. Remember, this fuzzy underscore plot underscore data will be sent back to the front end as part of the JSON response. You'll need to make sure your front end JavaScript is ready to handle this data and plot it accordingly using a library like Plotly.js or any other plotting library Here's a recap of what you should ensure on the front end. Make a request to the analyze endpoint when you need to perform the analysis. Receive the response and extract the fuzzy underscore plot underscore data. Plot the data using the plotting library. For example, with Plotly.js you would use the extracted X and MF underscore asterisk arrays to create the traces for your plots. For example, pseudo code for Plotly.js on the front end could look like this. In your HTML ensure you have an element with the ID symmetry membership function to target for this plot and similarly for the plots. Lastly, make sure your web server is properly serving the necessary static files and that your JavaScript files are correctly included in your HTML so that when you make these requests everything is in place to handle the response and plot the data. Yes, in the provided fuzzy underscore logic function there is an issue with the return statement. The return keyword immediately exits the function which means any code after the return statement will not execute. The fuzzy underscore plot underscore data dictionary is being created after the return statements that conclude the function with the output wave type so fuzzy underscore plot underscore data will never be reached and returned. To fix this, you should ensure that the fuzzy underscore plot underscore data is assembled and returned within the scope of the function before any return statement that would exit the function. Here's how to adjust the code. With this change the fuzzy underscore logic function now properly returns both the identified wave type and the data needed for plotting the fuzzy parameters. The output underscore wave is determined first, followed by the creation of fuzzy underscore plot underscore data and finally, both return together. The JavaScript code snippet you've provided sets up an event listener that triggers once the DOM content is fully loaded. It performs the following actions. Selects elements from the DOM for manipulation including drop downs, sliders and divs for graphs. Defines update output, updates the displayed output wave, detection error and unknown percentage with the data received from the server. Defines update input graph, uses plotly to plot the input waveform graph. Defines analyze waveform, sends the selected waveform and noise amplitude to the servers, analyzes root and handles the response. Defines plot fuzzy logic parameters, plots fuzzy logic parameters using plotly but it needs correction to properly handle multiple traces for membership functions and rule activations. The plot fuzzy logic parameters function is incomplete and has a few issues that need to be addressed. The function attempts to plot the membership functions and rule activations but it doesn't correctly separate the traces for low, mid and high membership functions. Each membership function should be its own trace. The fetch call to get fuzzy logic parameters will not work as expected because the flask root get fuzzy logic parameters is not defined in the back-end code provided. This root needs to be implemented on the server side to respond with the fuzzy logic parameters. The plotting of rule activations assumes a single trace. However, you typically want to plot the activation as a separate trace for clarity. Here's how you could correct the plot fuzzy logic parameters function. You would also need to ensure that your HTML has div elements with corresponding IDs like symmetry membership function, sharpness membership function and rule activation for the plots. Lastly, make sure the analyze root in flask returns the necessary fuzzy logic plotting data within the JSON response and that the root get fuzzy logic parameters is defined and implemented to serve the fuzzy logic parameters. The existing analyze root should already be providing that information so you might not need a separate, yet fuzzy logic parameters root unless you want to load the fuzzy parameters independently of the waveform analysis. Your Python flask code is set up to handle post requests the analyze root, perform the analysis and return the results along with fuzzy logic data as a JSON response. Here's what you need to update to ensure that the code functions correctly. Ensure that the fuzzy underscore logic function returns the fuzzy logic plot data. You have already modified the fuzzy underscore logic function to return both the output underscore wave and fuzzy underscore plot underscore data, which is good. The analyze underscore signal function is correctly updated to return the fuzzy underscore data as well. Make sure to catch errors in your root. If there's any possibility of an error in your signal generation, noise addition or fuzzy logic analysis, you should handle these errors to prevent the server from crashing and to send a meaningful response back to the client. Here is an updated version of your flask root with error handling added. With this updated root, if an error occurs during the processing of the waveform analysis, the server will catch the exception and return a JSON object with an error message and a 500 status code, indicating a server error. Remember, in your front-end JavaScript, you should also handle the case where the server returns an error. Check the response for an error field and handle it appropriately, such as by showing an error message to the user. The error message unexpected token, less than, less than. Doctype is not valid.JSON usually indicates that the response from the server was not JSON, but HTML. This often happens when you make a request to a root that is not found, 404 error, or there's a server-side error that results in an HTML error page being sent instead of a JSON response. Here are some steps to troubleshoot and fix this issue. Check the server root. Make sure the root your requesting exists on the server and is set up to return JSON. In the code snippets you've provided, you're making a request to get fuzzy logic parameters, but this root isn't defined in your flask application. Ensure that you have a corresponding ad-app.root, get fuzzy logic parameters, methods equals, yet, in your flask app. Error handling on the server ensure that your flask roots are correctly handling errors and still returning JSON even when an error occurs. The flask error handler should catch exceptions and return a JSON response with an appropriate HTTP status code. Check the response before pausing as JSON. In your JavaScript code, before you attempt to pass the response as JSON, check the response as status code to ensure it's 200, OK? Handle the error appropriately. Here's an example of how you can do this. Content type header. Ensure the server is setting the content type header to application, JSON when returning the response. Flask's JSONified is this automatically, but if you're constructing responses manually, you need to set this header. Check the network response. Use the browser's developer tools to inspect the network response from your fetch request. Look at the preview or response tab to see what's being returned. If it's HTML, it will likely start with less than. Doctype HTML greater than, which will help you to understand what the issue might be. Server logs. Check the server logs for any unhandled exceptions or errors that may give clues as to why the server is returning HTML instead of JSON. Once you've ensured that the root exists and is returning the correct data, your front-end JavaScript should be able to pass the JSON without encountering the unexpected token. Less than, error. The 404 status code in the log message indicates that the root, get fuzzy logic parameters for the server. To resolve this issue, you need to define this root in your flask application. Here's how you can define the get fuzzy logic parameters root. Make sure to replace the placeholder comments with actual logic to compute the fuzzy logic parameters based on your application's needs. Once this root is properly defined, your front-end JavaScript's fetch call to get fuzzy logic parameters should receive a valid JSON response, assuming there are no other errors in the computation and response generation. You can use this application after making these changes so that the new root is registered and available for requests. Yes, you can certainly pass all the necessary data for plotting directly from your existing analyzed root without needing an extra root like your fuzzy logic parameters. This approach can simplify your application by reducing the number of HTTP requests and consolidating the logic in a single root. To do this, you should modify the analyzed root in your flask application to include the data required for plotting the fuzzy logic parameters in its response. The data for the membership functions, rule activations, and aggregated output are all included in the JSON response returned by the analyzed root. Here's how you can adjust your existing analyzed root. With this setup, when your front-end makes a post-request to analyze, it will receive not only the analysis results but also the fuzzy data necessary for plotting. Your JavaScript code can then use this data to render the plots using a library like plotly.js. Here's an example snippet of how the library has the advantage of keeping all related data in one response, reducing the complexity of your front-end code and potentially improving the responsiveness of your application by minimizing the number of server requests. The range of the symmetry functions, or any membership functions in fuzzy logic, typically depends on the context of your application and how you define the universe of discourse for the variables you're working with. Range between minus 1 to 1, if you're measuring symmetry in a way that allows for negative values, perhaps representing some form of asymmetry or inverse relationship, in a sense. This range is useful when you want to represent a variable that can have both positive and negative impacts or characteristics. Range between 0 to 1, this is more common in fuzzy logic, especially when dealing with probabilities, degrees of membership, or any other metric that doesn't go into negative territory. For instance, if you're measuring how closely a signal resembles a perfect symmetrical form, a range of 0 to 1 could be more appropriate, with 0 representing no symmetry and 1 representing perfect symmetry. For analysis in the context of waveform analysis, like in your application, you typically use a range from 0 to 1. This is because symmetry is usually measured as a degree of similarity between two sides of the waveform, where 0 would represent no symmetry, completely asymmetrical, and 1 would represent perfect symmetry. That said, if your analysis method or theoretical framework specifically requires the use of a minus 1 to 1 range to capture some form of inverse or negative symmetry, you should use that instead. The key is to ensure that the range represents the phenomena you're analyzing and fits the logic of your fuzzy system. In fuzzy logic, rule activation charts and the decision-making process involve evaluating how strongly different rules apply given certain inputs. Let's break down these concepts, especially in the context of your waveform detection system. Rule activation in fuzzy logic refers to the degree to which a particular fuzzy rule is applicable, based on the current input values. Each rule in a fuzzy logic system is typically a simple rule might be, if the symmetry is high and the sharpness is low, then the waveform is square. In your system, you likely have a set of rules like this to determine the type of waveform. Each rule's activation level is determined by the input values, in your case, symmetry and sharpness. The degree of membership in the respective fuzzy sets, low, medium, high, are these inputs as computed, and then these degrees are combined, usually using logical operators like and R to determine the rule's activation level. This visualizes the degree of activation for each rule across the range of input values. For instance, it could show how the activation level of the waveform is square, rule varies as the symmetry and sharpness change. This visualization helps understand which rules are most influential for different input conditions. The actual decision, in this case, identifying the waveform type, is derived through a process known as defuzzification. This process converts the fuzzy rule activations into a single crisp output. There are several methods for defuzzification, but a common one is the centroid method, which finds the center of gravity of the aggregated output fuzzy set. Here's a simplified outline of how the decision might be made in your system. Evaluate each rule, based on the input values, symmetry and sharpness, determine the activation level of each rule. For example, one rule might be significantly activated when symmetry is high and sharpness is low, suggesting a square waveform. Aggregate the activations, combine the activations of all rules to form a single fuzzy set. This aggregation represents the overall decision of the system in a fuzzy manner. Defuzzify, use a method like the centroid to find a crisp value from the aggregated fuzzy set. This value represents the final decision. In your system, this might be a value that determines whether the waveform is more like a square, triangle or trapezoid. If the centroid falls in a range associated with square, the system decides the waveform is square. If it falls in a range for triangle, it decides on a triangle. Similarly for trapezoid. In summary, the rule activation chart shows how applicable each rule is under different input conditions, and the decision output waveform is determined by aggregating these activations and then defuzzifying the aggregate to a single crisp value that indicates the type of waveform. To enhance the understanding of the decision-making process in your physiological waveform detection system using fuzzy logic, you can plot additional elements beyond the symmetry and sharpness membership functions and the rule activation chart. Here are some suggestions. The aggregated output fuzzy set. After individual rule activations are determined, they're typically combined into a single fuzzy set representing the overall output decision before defuzzification. Plotting this aggregated output shows how the various rules contribute collectively to the final decision. Defuzzification process visualization illustrate the defuzzification process, such as the centroid method. This could involve plotting the aggregated output fuzzy set and indicating the center of gravity, centroid, on this plot, which is the crisp value used as the final output. Input signal and noisy signal plot the original input signal alongside the noisy signal. This visual comparison can help in understanding how noise affects the waveform and the challenges in detecting the correct waveform type. Symmetry and sharpness over time plot the calculated symmetry and sharpness values over time or over the signal. This can help in understanding how these metrics vary across the signal and how they influence the fuzzy logic decision. Temporal evolution of rule activation if your system's inputs change over time like in a time series, plotting the evolution of rule activations over time can provide insights into the dynamic decision-making process. Confidence level or degree of membership if available, plot the degree of membership or confidence level for the final decision. This can help in understanding the certainty of the decision made by the fuzzy logic system. Comparison of different waveforms if your system can handle multiple waveform types a comparative plot showing how different types of waveforms are processed differently by the system can be insightful. Aerometrics over time if you're calculating detection error or unknown percentages plotting these metrics over time or against various parameters can provide insights into the performance of the system under different conditions. Each of these plots contributes to a more comprehensive understanding of how the fuzzy logic system processes input data and arrives at a decision. They can be particularly useful for debugging, fine-tuning the system and for educational purposes to illustrate the concepts of fuzzy logic in a practical application. To add both the aggregated output fuzzy set plot and the defuzzification process visualization you'll need to modify the back-end to compute and send the necessary data and then update your front-end JavaScript to render these plots. Here's a guide on how to do this. Aggregated output fuzzy set this is the combined result of all the rule activations. You should already have this data in your fuzzy underscore logic function referred to as aggregated in your existing code. Defuzzification process visualization typically this involves showing where the centroid falls within the aggregated output. You should calculate the centroid as you do for determining the output wave and send this value along with the aggregated output data. Here's how you can modify the fuzzy underscore logic function. Plotting the aggregated output fuzzy set use the aggregated output data from the response to plot this fuzzy set. Visualizing the defuzzification process mark the centroid on the aggregated output plot. Here's an example of how you might modify your JavaScript. Ensure that your HTML contains elements with the ID's aggregated output and defuzzification for these new plots. These editions will provide a visual representation of the aggregated output of your fuzzy logic system and clearly show the process of defuzzification, enhancing the understanding of how the final decision is made. The image you've uploaded shows two plots, both appear to be the aggregated output fuzzy set with the second plot intended to include a centroid line, which seems to be missing or not visible. To address these issues, here's what you can do. Ensure the centroid line is visible. If the centroid line is not visible, it might be because the line's y-values are not visible. If the centroid line is not visible, it might be because the line's y-values do not span the full range of the y-axis, or the color of the line is not contrasting enough against the background. Ensure the plots are not repeated. If the same plot is being shown twice, it might be because the plotting function is being called twice or the same div element is being targeted twice. Ensure each plot has a unique div ID and the plotting function is called once per plot. Here is an updated JavaScript snippet with some potential fixes. In this snippet, we can add a marker to ensure it's visible. We've added a shapes property in the layout to draw a line, which is an alternative to adding the line as a separate trace. We've ensured plotly. New plot is called once for the aggregated output plot. Ensure that the back-end sends the correct centroid value and that it is appropriately formatted for plotlet to interpret. If the centroid line is still not visible after these changes, it might be due to it coinciding with a peak or trough in the aggregated fuzzy set, making it blend into the plot. Adjusting the Z-index, which is not directly available in plotly, but can be mimicked by plotting order or the color to something more contrasting can help. You may also consider adding text annotations or markers to highlight the centroid more clearly.