feat(linkedin-thought-leadership): v1.0.0 — initial open-source import
Build LinkedIn thought leadership with algorithmic understanding, strategic consistency, and AI-assisted content creation. Updated for the January 2026 360Brew algorithm change. 16 agents, 25 commands, 6 skills, 9 hooks, 24 reference docs. Personal data sanitized: voice samples generalized to template, high-engagement posts cleared, region-specific references replaced with placeholders. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7194a37129
commit
39f8b275a6
143 changed files with 32662 additions and 0 deletions
|
|
@ -0,0 +1,63 @@
|
|||
import type { TrendDirection } from "../models/types.js";
|
||||
|
||||
/**
|
||||
* Calculate arithmetic mean of values.
|
||||
* Returns 0 for empty array.
|
||||
*/
|
||||
export function mean(values: number[]): number {
|
||||
if (values.length === 0) return 0;
|
||||
const sum = values.reduce((acc, val) => acc + val, 0);
|
||||
return sum / values.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate population standard deviation.
|
||||
* Returns 0 for empty or single-element array.
|
||||
*/
|
||||
export function standardDeviation(values: number[]): number {
|
||||
if (values.length <= 1) return 0;
|
||||
|
||||
const avg = mean(values);
|
||||
const squaredDiffs = values.map((val) => Math.pow(val - avg, 2));
|
||||
const variance = mean(squaredDiffs);
|
||||
|
||||
return Math.sqrt(variance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine trend direction based on percentage change.
|
||||
* Returns "up" if change > threshold, "down" if change < -threshold, "stable" otherwise.
|
||||
* Default threshold is 5%.
|
||||
*/
|
||||
export function trendDirection(
|
||||
current: number,
|
||||
previous: number,
|
||||
threshold: number = 5
|
||||
): TrendDirection {
|
||||
const change = percentChange(current, previous);
|
||||
|
||||
if (change > threshold) return "up";
|
||||
if (change < -threshold) return "down";
|
||||
return "stable";
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate percentage change between current and previous values.
|
||||
* Returns 0 if previous is 0.
|
||||
*/
|
||||
export function percentChange(current: number, previous: number): number {
|
||||
if (previous === 0) return 0;
|
||||
return ((current - previous) / previous) * 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate how many standard deviations a value is from the mean.
|
||||
* Returns 0 if standard deviation is 0.
|
||||
*/
|
||||
export function deviationsFromMean(value: number, values: number[]): number {
|
||||
const avg = mean(values);
|
||||
const stdDev = standardDeviation(values);
|
||||
|
||||
if (stdDev === 0) return 0;
|
||||
return (value - avg) / stdDev;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue