Sender | Message | Time |
---|---|---|
15 Mar 2025 | ||
04:24:57 | ||
16:57:20 | ||
16 Mar 2025 | ||
17:03:35 | ||
17 Mar 2025 | ||
Hi. I have a problem. I have a schedulable entity (an observation) which has a certain earliest start time, latest stop time, and duration. it can start anytime between start and end, but will only ever last exactly the length of the duration. I want to think about the probability of the observation being under way during any particular hour. An array of 24 bins, one for each hour, I call "time bins" and is the solution I'm seeking. I believe this forms a probability density function. I have previously analyzed this as forming a kind of trapezoid, the important points being 0, start, start + duration, end - duration, end, and 24. You can make a piecewise function for this trapezoid (although it's grosser when you handle wrapping over midnight). My previous solution worked by treating each bin as an integration over a little bit of this piecewise function, which winds up using the trapezoid rule since the function pieces are so simple. I'm trying to figure out how to approach this in J. My gut feeling is that following the above implementation strategy will be difficult and it may be easier to say "the resolution of my answer is seconds", and then implement the piecewise function using @. and I. , execute it for every second in a day, and then use _3600\ to sum up each hour bin. I'm not sure I'd lose anything from this but I thought I'd ask if there is an easier way to do it the other way, or if there is a better approach than the one I'm describing here, or if there are performance considerations with any of these approaches. | 22:36:39 | |
This sounds very familiar.. https://discord.com/channels/821509511977762827/821511195629715466/1217197619617726606 | 23:19:33 | |
18 Mar 2025 | ||
yes, I did ask about this last year | 14:45:38 | |
thanks! I wasn't sure where to find the previous discussion, but I am again thinking about how to solve problems in J | 14:45:58 | |
one thing raulmiller said before which I'm curious about now is, suppose I want to calculate start+duration and end-duration. I'm curious if it would be possible to make a verb or adverb or something v so that we have something like start (duration ??? v) end . Something where start and end could each be arrays and the duration is passed in separately | 14:52:14 | |
also twobular turned out to be right, they don't care about the resolution below a second (even below a minute is pretty debatable) | 15:58:09 | |
if you want to pass in duration as a separate argument to start and end, then you could make an adverb which you'd use like start (duration adverb) end . however, unless the duration never really changes, i recommend writing a verb that takes as argument a list of the things you need, such as the monadic verb start,end,duration or maybe the dyadic duration verb start,end | 16:10:42 | |
I'm still learning the basics of J, how would you write that as an adverb? | 16:11:45 | |
I am realizing I'm a little too impatient with trying to learn J, and while I wasn't quite mature enough to understand the help before, I'm probably even further from it now, but I need to become comfortable with this taking a long time | 16:12:28 | |
probably something like | 16:13:35 | |
I think taking three arguments as an array makes sense, I would probably use 'start duration end' =. y and then proceed to write the arithmetic. not sure what the right way to do that tacitly would be | 16:13:50 | |
don't worry about tacit to start off with | 16:14:07 | |
OK | 16:14:14 | |
just get code that works and eventually you can translate it partially or wholly to tacit. but it will make reading and writing tougher until you have enough practice | 16:16:34 | |
Is this {{ syntax new? I thought you had to define things like := verb define ... ) ? This seems much nicer | 16:16:38 | |
yeah it's new. the old thing still works | 16:17:09 | |
the old version would be which is a more readable synonym for | 16:19:03 | |
I found the dangling close parens pretty unaesthetic | 16:19:20 | |
per my query above, does using @. with I. seem like the right way to handle a piecewise function? | 16:20:24 | |
j verb definitions look awful | 16:21:30 | |
I don't see what's wrong with verb =. {{ ... }} | 16:22:30 | |
you could use those tools but since you are writing explicit you can also use control words like if. a do. b else. c end. | 16:23:07 | |
to use @. effectively you'll want a bit of tacit | 16:25:00 | |
Who are “they”? | 16:25:11 | |
they are my users, who don't consider this tool to be doing anything so rigorous that it matters whether it is accurate much below a minute | 16:25:42 | |
which suggests to me that doing the work the way I was trying might be harder than another approach where I just evaluate a function for every minute or every second of the day and sum it up, which seems to me like it might be easier and maybe even perform better | 16:26:46 | |
there are less than 1e5 seconds in a day so worth a shot i guess. probably it would be more efficient to process the whole list of jobs once and get your statistics for the day instead of sifting through it thousands of times, but it's still not totally clear to me what precise variant of a histogram you're trying to implement so i'm just guessing | 16:35:33 |