nancygold's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Thursday, October 31st, 2024

    Time Event
    12:29a
    Symta is too difficult even for me
    So as you know already I have to generate a lot of unique characters procedurally.
    And any generation involves some distribution.
    So I pulled out of my ass the following statistics:
    70% of ladies have long hair
    25% have mid hair
    5% have short hair

    70% of men have short hair
    20% have mid hair
    5% have long hair
    5% are fully bald

    In game these are defined as a list
    MaleHairLength: 70,short 20,mid 5,long 5,bald
    These allow me to settle on the hair length of a character.
    I had some code to pick a random sample from such a distribution.

    MaleHairLength.find(s~+=?0; p~^(Me{?0}.z*)<<s~).1

    That is cryptic and it does really cryptic things inside the find's lambda and (implicitly) outside of it.
    Now the problem is that I already forgot the implcit variables semantics I introduced years ago.
    Since most of the code is not command line oneliners or math shit.
    What is worse, I have never documented it.
    So now I had to go over the macros implementing these constructs deciphering them.
    And obviously these macros are not simple.

    TLDR: I need to document at least the harder parts.

    Current Mood: contemplative
    Current Music: Anvil of Dawn OST
    12:17p
    ChatGPT
    [info]necax claims there is a shorter algorithm to sample from a population, but ChatGPT comes with exactly the same algorithm I invented, which it calls "cumulative summing method":
    https://chatgpt.com/share/67236748-da18-800d-bcd1-a7bf2ba9d23c

    It is completely equivalent to my
    list.outcome = $find(s~+=?0; p~^(Me{?0}.z*)<<s~).1
    method, except that it produces a list of K samples, instead of just one.

    import random
    
    def custom_choices(population, weights, k=1):
        cumulative_weights = []
        total = 0
        
        # Build cumulative weights
        for weight in weights:
            total += weight
            cumulative_weights.append(total)
        
        # Generate samples
        samples = []
        for _ in range(k):
            rand = random.uniform(0, total)
            for item, cum_weight in zip(population, cumulative_weights):
                if rand < cum_weight:
                    samples.append(item)
                    break
                    
        return samples
    
    # Test it with your distribution
    population = ['short', 'mid', 'long', 'bald']
    weights = [70, 20, 5, 5]
    samples = custom_choices(population, weights, k=10)
    print(samples)


    Current Mood: contemplative
    1:00p
    Cops came again to harrass me
    Currently ACABs impute me prostitution.
    Last time they claimed I boiled a cat.
    Before that they insisted I have a firearm.
    And then that I'm a racist and a russophobe,
    That I vandalize property and disturb order.
    These transphones make up a reason of every type.

    It is easy to harass trans folk.
    Instead of going after actual criminals.
    Who have real guns, not imaginary ones.
    And if they want a whore, they should arrest their moms.

    But I guess this time municipality unleashed them.
    Since I filled multiple complaints against the municipality,
    which impedes my inburgering.

    Current Mood: annoyed
    Current Music: Howard Drossin - Sendai Enclave
    6:32p
    The Genesis of Morals
    https://youtu.be/Ehv7-T_w9Hw?t=1320

    pretty much this

    Current Mood: amused

    << Previous Day 2024/10/31
    [Calendar]
    Next Day >>

About LJ.Rossia.org