Derive room occupancy from number of motion events in given timeframe

I’m trying to create a room activity/occupancy sensor for bedrooms that basically determines if someone is actively occupying a room vs just going in and out or moving while asleep. I’m very new to HA, so maybe this is actually somewhat easy to do and I just don’t have enough knowledge of the system. In my head, I’d like to set up a sensor (or maybe an automation) that is based on a certain number of “on” states over a set period of time. E.g. my wife moves somewhat frequently while sleeping, but I don’t want these frequent but brief movements to activate the sensor/automation. I know my sensors have a 30 second cooldown time, so the watch interval would likely need to be a few minutes; let’s say if there are 3-4 “on” events over a 3 minute period, that would indicate active occupancy. In my searching I’ve come across a few mentions of a Beyesian sensor, but I didn’t understand them enough to know if that was even going down the right path. Any help or suggestions would be greatly appreciated!

Here is the best description of the bayesian sensor that I’ve seen in layman’s terms. Might help you decide if it’s right for your project. How Bayes Sensors work, from a Statistics Professor (with working Google Sheets!)