Qu

hourly_profile

Builtin index · Signal processing

result = hourly_profile(x, fs, [stat="std"])

Input: x, fs, stat · Output: result

What it is

x: a length-N real vector; fs: a number (Hz); stat (optional string).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = hourly_profile(x, fs, [stat="std"])
x vectorx: a length-N real vector.
fs numberfs: a number (Hz).
stat string, optional (default "std")stat (optional string).
result vector
Returns a length-24 real vector, one bin per hour-of-day. A daily rhythm shows up here as a shape, where a spectrum would only give it a peak.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

## periodic_profile: a burst that recurs every 2 seconds, folded onto one cycle

fs = 200
n = 0:1:1999          # 10 seconds

t = n / fs
x = 0.05*randn(2000, seed=6)
x = x + where((t mod 2.0) < 0.1, 1.0, 0.0)   # a short spike once per 2s cycle

prof = periodic_profile(x, fs, 2.0, 20, stat="mean")
print("periodic_profile bins: {length(prof)}, spike bin mean = {max(prof)}, baseline ~ {prof[10]}")

## hourly_profile: a day/night sinusoid, sampled once per minute over 2 days

fs_h = 1.0/60.0
n_h = 0:1:2879        # 2 days at 1 sample/min

t_h = n_h / fs_h
hour_of_day = (t_h/3600) mod 24
xh = sin(2*pi*hour_of_day/24) + 0.1*randn(2880, seed=7)
hp = hourly_profile(xh, fs_h, stat="mean")
print("hourly_profile: {length(hp)} bins, quietest hour idx = {find_peaks(-hp)[0]}")

## minutely_profile: activity concentrated in the first 5 minutes of each hour

fs_m = 1.0
n_m = 0:1:10799       # 3 hours at 1 Hz

t_m = n_m / fs_m
minute_of_hour = (t_m/60) mod 60
xm = where(minute_of_hour < 5, 1.0, 0.0) + 0.05*randn(10800, seed=8)
mp = minutely_profile(xm, fs_m, stat="mean")
print("minutely_profile: {length(mp)} bins, busiest minute idx = {find_peaks(mp)[0]}")

## daily_profile: weekday/weekend pattern, one sample per hour over 3 weeks

fs_d = 1.0/3600.0
n_d = 0:1:503         # 21 days at 1 sample/hour

t_d = n_d / fs_d
day_of_week = (t_d/86400) mod 7
xd = where(day_of_week < 5, 1.0, 0.0) + 0.05*randn(504, seed=9)   # higher on weekdays

dp = daily_profile(xd, fs_d, stat="mean")
print("daily_profile: {length(dp)} bins (0=day0..6), values = {dp}")

## monthly_profile: an annual cycle, one sample per day over ~2 years

fs_mo = 1.0/86400.0
n_mo = 0:1:729        # 2 years at 1 sample/day

t_mo = n_mo / fs_mo
xmo = sin(2*pi*t_mo/31557600) + 0.05*randn(730, seed=10)
mop = monthly_profile(xmo, fs_mo, stat="mean")
print("monthly_profile: {length(mop)} bins, values = {mop}")
output
periodic_profile bins: 20, spike bin mean = 0.994081, baseline ~ -0.005544
hourly_profile: 24 bins, quietest hour idx = 17
minutely_profile: 60 bins, busiest minute idx = 3
daily_profile: 7 bins (0=day0..6), values = [0.999204, 1.007344, 1.00092, 1.008568, 1.005545, 0.008587, -0.005461]
monthly_profile: 12 bins, values = [0.258528, 0.701187, 0.950701, 0.941434, 0.711217, 0.260041, -0.255472, -0.69034, ... (12 elements)]

from signal-processing

How it works

hourly_profile(x, fs, [stat="std"]) — periodic_profile preset: a 24-hour cycle cut into 24 hour-of-day bins.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.