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


Messages In This Thread
Binomial distribution in VMS - by bi3mw - 17-08-2024, 12:33 AM
RE: Binomial distribution in VMS - by bi3mw - 17-08-2024, 12:28 PM
RE: Binomial distribution in VMS - by bi3mw - 17-08-2024, 12:47 PM
RE: Binomial distribution in VMS - by RobGea - 17-08-2024, 03:35 PM
RE: Binomial distribution in VMS - by RobGea - 17-08-2024, 04:38 PM
RE: Binomial distribution in VMS - by bi3mw - 17-08-2024, 06:38 PM
RE: Binomial distribution in VMS - by nablator - 18-08-2024, 08:18 PM
RE: Binomial distribution in VMS - by bi3mw - 18-08-2024, 01:44 PM
RE: Binomial distribution in VMS - by nablator - 18-08-2024, 05:06 PM
RE: Binomial distribution in VMS - by RobGea - 18-08-2024, 04:14 PM
RE: Binomial distribution in VMS - by bi3mw - 18-08-2024, 04:46 PM
RE: Binomial distribution in VMS - by bi3mw - 18-08-2024, 05:36 PM
RE: Binomial distribution in VMS - by nablator - 18-08-2024, 06:45 PM
RE: Binomial distribution in VMS - by bi3mw - 19-08-2024, 06:08 PM
RE: Binomial distribution in VMS - by nablator - 19-08-2024, 06:43 PM
RE: Binomial distribution in VMS - by bi3mw - 19-08-2024, 07:09 PM
RE: Binomial distribution in VMS - by bi3mw - 19-08-2024, 07:49 PM
RE: Binomial distribution in VMS - by nablator - 19-08-2024, 08:36 PM
RE: Binomial distribution in VMS - by nablator - 19-08-2024, 09:06 PM
RE: Binomial distribution in VMS - by bi3mw - 19-08-2024, 09:12 PM
RE: Binomial distribution in VMS - by nablator - 19-08-2024, 09:40 PM
RE: Binomial distribution in VMS - by bi3mw - 20-08-2024, 03:30 PM
RE: Binomial distribution in VMS - by bi3mw - 21-08-2024, 05:40 PM
RE: Binomial distribution in VMS - by Koen G - 21-08-2024, 07:06 PM
RE: Binomial distribution in VMS - by bi3mw - 21-08-2024, 07:11 PM
RE: Binomial distribution in VMS - by Koen G - 21-08-2024, 07:25 PM
RE: Binomial distribution in VMS - by bi3mw - 21-08-2024, 07:39 PM
RE: Binomial distribution in VMS - by Koen G - 21-08-2024, 08:17 PM
RE: Binomial distribution in VMS - by bi3mw - 22-08-2024, 07:59 PM
RE: Binomial distribution in VMS - by bi3mw - 23-08-2024, 11:24 PM
RE: Binomial distribution in VMS - by bi3mw - 25-08-2024, 12:23 AM
RE: Binomial distribution in VMS - by RobGea - 25-08-2024, 06:11 PM
RE: Binomial distribution in VMS - by bi3mw - 26-08-2024, 10:27 AM
RE: Binomial distribution in VMS - by RobGea - 26-08-2024, 03:38 PM
RE: Binomial distribution in VMS - by bi3mw - 26-08-2024, 05:08 PM
RE: Binomial distribution in VMS - by RobGea - 26-08-2024, 05:54 PM
RE: Binomial distribution in VMS - by bi3mw - 26-08-2024, 06:02 PM
RE: Binomial distribution in VMS - by RobGea - 26-08-2024, 06:08 PM
RE: Binomial distribution in VMS - by bi3mw - 26-08-2024, 08:34 PM
RE: Binomial distribution in VMS - by RobGea - 26-08-2024, 10:45 PM
RE: Binomial distribution in VMS - by bi3mw - 27-08-2024, 03:32 PM
RE: Binomial distribution in VMS - by RobGea - 27-08-2024, 09:41 PM
RE: Binomial distribution in VMS - by ReneZ - 27-08-2024, 10:57 PM
RE: Binomial distribution in VMS - by bi3mw - 28-08-2024, 01:28 PM
RE: Binomial distribution in VMS - by nablator - 28-08-2024, 02:17 PM
RE: Binomial distribution in VMS - by bi3mw - 28-08-2024, 03:03 PM
RE: Binomial distribution in VMS - by RobGea - 28-08-2024, 06:04 PM
RE: Binomial distribution in VMS - by bi3mw - 28-08-2024, 06:25 PM
RE: Binomial distribution in VMS - by RobGea - 28-08-2024, 08:06 PM
RE: Binomial distribution in VMS - by bi3mw - 28-08-2024, 08:19 PM
RE: Binomial distribution in VMS - by RobGea - 28-08-2024, 10:02 PM
RE: Binomial distribution in VMS - by bi3mw - 28-08-2024, 10:44 PM
RE: Binomial distribution in VMS - by RobGea - 28-08-2024, 10:53 PM
RE: Binomial distribution in VMS - by bi3mw - 28-08-2024, 11:02 PM
RE: Binomial distribution in VMS - by RobGea - 28-08-2024, 11:12 PM
RE: Binomial distribution in VMS - by bi3mw - 28-08-2024, 11:52 PM
RE: Binomial distribution in VMS - by RobGea - 29-08-2024, 12:03 AM
RE: Binomial distribution in VMS - by bi3mw - 29-08-2024, 12:18 AM
RE: Binomial distribution in VMS - by bi3mw - 29-08-2024, 10:52 PM
RE: Binomial distribution in VMS - by bi3mw - 30-08-2024, 10:36 PM
RE: Binomial distribution in VMS - by RobGea - 06-09-2024, 08:08 PM
RE: Binomial distribution in VMS - by lelle - 06-09-2024, 09:47 PM
RE: Binomial distribution in VMS - by bi3mw - 07-09-2024, 02:24 AM
RE: Binomial distribution in VMS - by Koen G - 07-09-2024, 09:06 AM
RE: Binomial distribution in VMS - by bi3mw - 07-09-2024, 09:22 AM
RE: Binomial distribution in VMS - by ReneZ - 08-09-2024, 01:53 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)