PersonaGroup

PersonaGroup is a powerful container for managing collections of personas. It provides methods for bulk generation, statistical analysis, and AI-powered insights.

Creating Groups

Build groups manually or generate them using distributions:

persona-group-example.ts
1const group = new PersonaGroup('Marketing Audience');
2
3// Add personas manually
4group.add(new Persona('Alice', { age: 25, occupation: 'Designer' }));
5group.add(new Persona('Bob', { age: 30, occupation: 'Developer' }));
6
7// Generate 100 personas from distributions
8group.generateFromDistributions(100, {
9 age: new NormalDistribution(30, 5),
10 occupation: new CategoricalDistribution([
11 { value: 'Developer', probability: 0.6 },
12 { value: 'Manager', probability: 0.4 }
13 ])
14});

Group Statistics

Analyze your persona groups with built-in statistical methods:

1const stats = group.getStatistics('age');
2console.log(`Average age: ${stats.mean}`);
3console.log(`Age range: ${stats.min} - ${stats.max}`);
4console.log(`Standard deviation: ${stats.stdDev}`);
5
6// Filter personas
7const seniors = group.filter(p => p.age > 50);
8console.log(`Seniors: ${seniors.length}`);

Key Methods

add()

Add a persona to the group.

const group = new PersonaGroup('My Team');
const persona = PersonaBuilder.create()
.withName('Alice')
.withAge(30)
.build();
group.add(persona);
console.log(group.size); // 1

remove()

Remove a persona by ID.

const removed = group.remove(persona.id);
console.log(removed); // true if found and removed

filter()

Filter personas based on criteria.

const developers = group.filter(p =>
p.occupation === 'Developer'
);
const seniors = group.filter(p =>
p.age >= 35
);

getStatistics()

Get statistical analysis of an attribute.

const ageStats = group.getStatistics('age');
console.log(ageStats.mean); // Average age
console.log(ageStats.median); // Median age
console.log(ageStats.stdDev); // Standard deviation

Properties

size

Number of personas in the group.

console.log(group.size); // Returns count of personas

personas

Array of all personas in the group.

const allPersonas = group.personas;
allPersonas.forEach(persona => {
console.log(persona.name);
});

name

Name of the persona group.

console.log(group.name); // "My Team"