Binomial distribution in VMS
#1
Question: What if the words in the VMS have been shortened or expanded with fill characters (here X) so that they end up corresponding to a binomial distribution (with whatever system)?

Here is a line from a comparative text ( regimen sanitatis ):

Input example:
Capitulum primum De regulis sumptis ex parte elementorum nostro corpori occurrentium ab extra

Output example:
Ca primum DeXXXXX regul sump exXXXX parteX elemento nost corpo occu abXXXX extra

Distribution in the entire, modified text ( regimen sanitatis ):

   

Code:
import sys import numpy as np from scipy.special import comb def calculate_binomial_distribution(n, max_length):     """Berechnet eine Binomialverteilung für Wortlängen."""     k_values = np.arange(1, max_length + 1)     # Berechne die Binomialverteilung für die Formel choose(9, k-1) / 2^9     probabilities = [comb(n, k-1) / (2 ** n) for k in k_values]       # Normiere die Verteilung     probabilities /= np.sum(probabilities)       return probabilities def adjust_word_lengths(words, target_distribution):     """Passt die Wortlängen an die Zielverteilung an, indem Wörter gekürzt oder verlängert werden."""     adjusted_words = []     max_word_length = len(target_distribution)       length_bins = np.arange(1, max_word_length + 1)     length_probs = np.array(target_distribution)       for word in words:         current_length = len(word)         target_length = np.random.choice(length_bins, p=length_probs)               # Falls die Zielwortlänge kleiner ist, kürze das Wort         if target_length < current_length:             adjusted_words.append(word[:target_length])         # Falls die Zielwortlänge größer ist, verlängere das Wort mit 'X'         elif target_length > current_length:             adjusted_words.append(word + 'X' * (target_length - current_length))         else:             adjusted_words.append(word)  # Wenn die Länge passt, bleibt das Wort unverändert       return adjusted_words def process_text(file_path):     """Liest den Text aus der Datei, passt die Wortlängen an und gibt den neuen Text zurück."""     try:         with open(file_path, 'r', encoding='utf-8') as file:             lines = file.readlines()     except FileNotFoundError:         print(f"Error: The file {file_path} was not found.")         sys.exit(1)     except IOError as e:         print(f"Error: An error occurred while reading the file: {e}")         sys.exit(1)       max_word_length = 15  # Maximale Wortlänge festlegen     n = 9  # Anzahl der Würfe für die Binomialverteilung       # Berechne die Binomialverteilung     target_distribution = calculate_binomial_distribution(n, max_word_length)       adjusted_lines = []     for line in lines:         words = line.split()         adjusted_words = adjust_word_lengths(words, target_distribution)         adjusted_lines.append(' '.join(adjusted_words))       return '\n'.join(adjusted_lines) def main():     if len(sys.argv) != 2:         print("Usage: python adjust_word_length.py <filename>")         sys.exit(1)       file_path = sys.argv[1]     new_text = process_text(file_path)     print("Modified text:")     print(new_text) if __name__ == "__main__":     main()

Quote:ChatGPT

One could design a volvelle that aims to change the word lengths of a text according to a specific distribution. This could be done through the use of rotating disks, each giving specific instructions on how words should be edited.

Example of a volvelle for word length manipulation

Here is a hypothetical description of what a volvelle could look like for this task:

    Circle 1: Defines the possible word lengths from 1 to 15 (depending on the maximum word length).
    Circle 2: Gives the probability for each word length based on a certain distribution (e.g. binomial distribution).
    Circle 3: Instructions for shortening or expanding words to achieve the target distribution.

Use of a volvelle

1. user enters the text.
2. volvelle is rotated to obtain the rules for shortening or expanding words.
3. instructions are applied to the text.
Reply
#2
Register or login to view the content
Reply
#3
Register or login to view the content
Reply
#4
Register or login to view the content
Reply
#5
Register or login to view the content
Reply
#6
Register or login to view the content
Reply
#7
Register or login to view the content
[+] 1 user says Thank You to RobGea for this post
Reply
#8
Register or login to view the content
Reply
#9
Register or login to view the content
[+] 1 user says Thank You to bi3mw for this post
Reply
#10
Register or login to view the content
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)