profile

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package profile defines the distribution presets that shape histomancer's per-day commit cadence, week-level burstiness, and time-of-day weighting.

Index

Constants

This section is empty.

Variables

View Source
var (
	Uniform = Profile{
		Name:       "uniform",
		PerDay:     PerDay{DayProb: 0.6, Min: 1, Max: 5, ExtraProb: 0.4, WeekendBias: 1.0, WeekendDays: defaultWeekend},
		Burstiness: Burstiness{InitialActiveProb: 0.7, ActiveToQuiet: 0.2, QuietToActive: 0.5, QuietMultiplier: 0.4},
		TimeOfDay:  TimeOfDay{WorkStart: 0, WorkEnd: 24, WorkBias: 0.0},
	}

	WorkHours = Profile{
		Name:       "workHours",
		PerDay:     PerDay{DayProb: 0.75, Min: 2, Max: 8, ExtraProb: 0.45, WeekendBias: 0.1, WeekendDays: defaultWeekend},
		Burstiness: Burstiness{InitialActiveProb: 0.8, ActiveToQuiet: 0.15, QuietToActive: 0.6, QuietMultiplier: 0.4},
		TimeOfDay:  TimeOfDay{WorkStart: 9, WorkEnd: 18, WorkBias: 0.9},
	}

	AfterWork = Profile{
		Name:       "afterWork",
		PerDay:     PerDay{DayProb: 0.55, Min: 1, Max: 4, ExtraProb: 0.3, WeekendBias: 1.5, WeekendDays: defaultWeekend},
		Burstiness: Burstiness{InitialActiveProb: 0.6, ActiveToQuiet: 0.25, QuietToActive: 0.5, QuietMultiplier: 0.3},
		TimeOfDay:  TimeOfDay{WorkStart: 19, WorkEnd: 24, WorkBias: 0.85},
	}

	WeekendWarrior = Profile{
		Name:       "weekendWarrior",
		PerDay:     PerDay{DayProb: 0.35, Min: 1, Max: 6, ExtraProb: 0.4, WeekendBias: 3.5, WeekendDays: defaultWeekend},
		Burstiness: Burstiness{InitialActiveProb: 0.5, ActiveToQuiet: 0.3, QuietToActive: 0.45, QuietMultiplier: 0.25},
		TimeOfDay:  TimeOfDay{WorkStart: 10, WorkEnd: 22, WorkBias: 0.75},
	}
)

Built-in distribution profiles.

Presets enumerates the built-in profiles in the order they should appear in interactive menus.

Functions

func ExpectedCommitsPerDay

func ExpectedCommitsPerDay(p Profile) float64

ExpectedCommitsPerDay returns the analytical expected commits per calendar day for p, factoring in the Markov chain stationary distribution, the weekend-vs-weekday mix, and the geometric per-day count distribution starting at Min with extra-commit probability ExtraProb capped at Max.

Useful both for the --density rescaling math and for users who want to know "what should I expect from this profile?" without running a simulation.

func Names

func Names() []string

Names returns the names of all presets in display order.

Types

type Burstiness

type Burstiness struct {
	// InitialActiveProb is the probability the first week of the range is active.
	InitialActiveProb float64

	// ActiveToQuiet is the per-week probability of transitioning active → quiet.
	ActiveToQuiet float64

	// QuietToActive is the per-week probability of transitioning quiet → active.
	QuietToActive float64

	// QuietMultiplier scales PerDay.DayProb during a quiet week (0..1).
	QuietMultiplier float64
}

Burstiness controls a two-state Markov chain at the week level that gates the per-day probabilities, producing realistic streaks of active and quiet weeks rather than independent per-day rolls.

type Override

type Override struct {
	DayProb     *float64
	Min         *int
	Max         *int
	ExtraProb   *float64
	WeekendBias *float64
	WeekendDays *[]time.Weekday
	WorkStart   *int
	WorkEnd     *int
	WorkBias    *float64

	// Density, when set and DayProb is not, rescales the (possibly-overridden)
	// profile's DayProb so the analytical expected commits/day matches this
	// target. Clamps to DayProb=1.0 if the target is unreachable with the
	// current Min/Max/ExtraProb; combine with --min/--max to push higher.
	Density *float64
}

Override layers user-supplied parameter values on top of a Profile. Each field uses a pointer so the zero-value Override is a no-op (every field nil = "no override, use the profile's value"). Construct one by setting only the fields the user actually overrode on the command line.

func (Override) Apply

func (o Override) Apply(p Profile) Profile

Apply returns p with any non-nil overrides written through. Individual parameter overrides are applied first; Density (when set) is applied last so it rescales DayProb against the post-override profile.

type PerDay

type PerDay struct {
	// DayProb is the baseline probability that a weekday commits at all.
	DayProb float64

	// Min and Max bound the number of commits on a committing day.
	Min int
	Max int

	// ExtraProb is the geometric "one more commit" probability applied while
	// the current count is below Max — biases toward Min but with a long tail.
	ExtraProb float64

	// WeekendBias is a multiplier applied to DayProb on WeekendDays. 0 = never
	// commit on the weekend, 1 = same as a weekday, >1 = more than a weekday.
	WeekendBias float64

	// WeekendDays enumerates which days of the week WeekendBias applies to.
	// Built-in presets ship with Saturday and Sunday; override per locale
	// (e.g. Iran uses Friday only; many GCC countries use Friday and Saturday).
	// A nil or empty slice falls back to {Saturday, Sunday} for backward
	// compatibility with profiles constructed in code without setting this
	// field explicitly.
	WeekendDays []time.Weekday
}

PerDay controls the per-day commit-count distribution.

type Profile

type Profile struct {
	Name       string
	PerDay     PerDay
	Burstiness Burstiness
	TimeOfDay  TimeOfDay
}

Profile bundles the three independent dimensions that determine a generated commit pattern: how many commits a typical day gets, how active vs. quiet weeks alternate, and where within a day commits cluster.

func ByName

func ByName(name string) (Profile, bool)

ByName returns the preset matching name, or ok=false if no such preset.

type TimeOfDay

type TimeOfDay struct {
	// WorkStart and WorkEnd define the "work hours" window in 24-hour clock,
	// with WorkEnd exclusive. WorkStart=0 and WorkEnd=24 mean "the whole day".
	WorkStart int
	WorkEnd   int

	// WorkBias is the probability that a commit's timestamp falls inside the
	// work-hours window vs. outside it.
	WorkBias float64
}

TimeOfDay controls where within a day commit timestamps land.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL