Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/AI_Brain / daemon/seed_statistics.cs |
| Date | Not specified in source |
| Repository | Janady13/AI_Brain |
| Revision | 6d0767aad08781eb5c4e1eb14a42ec92c437be78 |
| Branch | copilot/convert-python-files-to-csharp |
| Path or archive member | daemon/seed_statistics.cs |
| Original SHA-256 | 72821130972ad91b52396a9d0193e56418f21429873f9a88ce23e2004bf85283 |
| Git blob SHA | 1d51371540461c136623ef7887080d8a70aa21b6 |
| Reading-copy SHA-256 | 72821130972ad91b52396a9d0193e56418f21429873f9a88ce23e2004bf85283 |
Recovered source transcript
Download complete source text ↓142 lines · 5.1 KB
// Generate statistical priors for marketing campaigns
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
namespace AIBrain.Daemon
{
public class StatisticalPrior
{
public string Feature { get; set; }
public string FeatureType { get; set; }
public double MeanRoi { get; set; }
public double StdRoi { get; set; }
public double MeanCtr { get; set; }
public double StdCtr { get; set; }
public int SampleSize { get; set; }
public double Weight { get; set; }
public double BaselineBudget { get; set; }
public string Notes { get; set; }
}
public static class SeedStatistics
{
private static readonly string STATISTICAL_PRIORS_PATH =
Path.Combine(Path.GetDirectoryName(typeof(SeedStatistics).Assembly.Location) ?? ".",
"datasets", "statistical_reasoning.json");
private static List<StatisticalPrior> LoadPriors()
{
try
{
if (File.Exists(STATISTICAL_PRIORS_PATH))
{
var json = File.ReadAllText(STATISTICAL_PRIORS_PATH);
return JsonSerializer.Deserialize<List<StatisticalPrior>>(json) ?? new List<StatisticalPrior>();
}
}
catch
{
// Fall through to default
}
return new List<StatisticalPrior>
{
new StatisticalPrior
{
Feature = "omni-channel",
FeatureType = "channel",
MeanRoi = 2.2,
StdRoi = 0.5,
MeanCtr = 0.038,
StdCtr = 0.012,
SampleSize = 150,
Weight = 0.8,
BaselineBudget = 20000,
Notes = "Fallback statistical prior when curated dataset missing."
}
};
}
public static IEnumerable<string> GenStatistics(int limit)
{
var priors = LoadPriors();
var scenarios = new[]
{
"baseline", "aggressive", "defensive", "innovation", "efficiency",
"expansion", "stabilization", "premium", "retention", "accelerated"
};
var confidenceLevels = new[] { 0.68, 0.8, 0.9, 0.95 };
var budgetMultipliers = new[] { 0.75, 0.9, 1.0, 1.1, 1.25 };
var zScores = new Dictionary<double, double>
{
[0.68] = 0.994,
[0.8] = 1.282,
[0.9] = 1.645,
[0.95] = 1.96
};
int produced = 0;
foreach (var prior in priors)
{
var feature = prior.Feature ?? "unspecified";
var featureType = prior.FeatureType ?? "feature";
var meanRoi = prior.MeanRoi;
var stdRoi = prior.StdRoi;
var meanCtr = prior.MeanCtr;
var stdCtr = prior.StdCtr;
var sampleSize = prior.SampleSize;
var weight = prior.Weight;
var baselineBudget = prior.BaselineBudget;
var notes = prior.Notes ?? "Statistical benchmark from curated marketing runs.";
foreach (var scenario in scenarios)
{
foreach (var confidence in confidenceLevels)
{
var zScore = zScores.ContainsKey(confidence) ? zScores[confidence] : 1.96;
var marginRoi = Math.Round(zScore * stdRoi / Math.Sqrt(Math.Max(sampleSize, 1)), 3);
var marginCtr = Math.Round(zScore * stdCtr / Math.Sqrt(Math.Max(sampleSize, 1)), 4);
foreach (var multiplier in budgetMultipliers)
{
var scenarioBudget = Math.Round(baselineBudget * multiplier, 2);
var projectedRevenue = Math.Round(scenarioBudget * meanRoi, 2);
var statement =
$"Statistical prior: {Capitalize(scenario)} strategy for {featureType} " +
$"'{feature}' targets ROI {meanRoi:F3}x ±{marginRoi:F3} ({confidence:P0} CI) " +
$"and CTR {meanCtr:F4} ±{marginCtr:F4} from {sampleSize} runs; " +
$"allocate ${scenarioBudget:N2} to unlock ${projectedRevenue:N2} with weights {weight:F2}. Notes: {notes}";
yield return statement;
produced++;
if (produced >= limit)
yield break;
}
}
}
}
}
private static string Capitalize(string s)
{
if (string.IsNullOrEmpty(s))
return s;
return char.ToUpper(s[0]) + s.Substring(1);
}
public static void Main(string[] args)
{
SeedCommon.RunSeed("statistics", GenStatistics);
}
}
}