Language
Language: the statistics of words from the economy of their use.
LanguageElement(label, exponent=1.0)
Bases: Element
Language with the exponent lambda of its word frequencies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the language. |
required |
exponent
|
Annotated[float, StateSpec()]
|
The initial guess of the exponent, from which it is solved. |
1.0
|
Examples:
>>> from skcomplex.models.social.language import LanguageElement
>>> LanguageElement('language').exponent
1.0
Source code in src/skcomplex/models/social/language/_language.py
28 29 30 | |
LeastEffortInteraction(label, *, target, words)
Bases: Interaction
Probabilities of words that minimise the ratio of the mean cost C to the entropy H.
The probabilities that are stationary for C / H on the simplex are p_i = exp(-lambda c_i) / Z, for which
H = lambda C + ln Z. The ratio is stationary in lambda where H = lambda C, that is where ln Z = 0, which
solves the exponent. The sum reduces in log space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the element that holds |
required |
words
|
Annotated[str, RoleSpec()]
|
The path of the group of words, which hold |
required |
Examples:
>>> from skcomplex.models.social.language import LeastEffortInteraction
>>> LeastEffortInteraction('effort', target='language', words='words').words
'words'
Source code in src/skcomplex/models/social/language/_least_effort.py
42 43 44 45 46 47 48 49 50 51 | |
WordElement(label, cost=1.0, probability=0.0)
Bases: Element
Word with a quenched cost and the probability of its use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the word or the group. |
required |
cost
|
Annotated[float, StateSpec()]
|
The cost of the word. |
1.0
|
probability
|
Annotated[float, StateSpec()]
|
The initial guess of the probability, which the equation replaces. |
0.0
|
Examples:
>>> from skcomplex.models.social.language import WordElement
>>> WordElement('word', cost=1.0).cost
1.0
Source code in src/skcomplex/models/social/language/_word.py
31 32 33 34 35 36 37 38 39 | |
mandelbrot_least_effort(n_words=200)
Return the word frequencies that minimise the mean cost of a language over its entropy, a power law of rank.
A word of rank i costs log(i + 1), the length of its code, so the probabilities are (i + 1)^-lambda, where
lambda makes them sum to 1 (Giordano 2024 §6, after Mandelbrot 1953).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_words
|
int
|
The number of words. |
200
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the states |
Examples:
>>> from skcomplex.engine.runtime import Simulation
>>> from skcomplex.models.social.language import mandelbrot_least_effort
>>> trajectory = Simulation(mandelbrot_least_effort(50)).check().prepare().run(1.0).trajectory_
>>> round(float(trajectory.values('words.probability')[0].sum()), 6)
1.0
Source code in src/skcomplex/models/social/language/_word_frequencies.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |