▲ 1 r/paypal

Do merchants lose money when I use PayPal instead of bank cards?

Due to complications, it's hard to use my bank cards directly as they require confirmation with my banking apps which I recently lost access to.

However, these cards are connected to my Paypal. When paying with Paypal, no verification is needed, they went through perfectly.

The prices were the same for me. I am wondering if Paypal takes a cut for these transactions and the merchants end up making less money. Thank you.

reddit.com
u/AyrtonHS — 2 days ago

Voltage on chargers

So I brought my PS4 from Taiwan to France. Originally things were fine when I used the original charger that had label 125 volts. However, I only have one adapter and changing it is annoying.

I found a charger that has the European plug that can seemingly power my PS4 with no adapters. However I'm worried about the voltage. My PS4 can handle 220-240 volts (written on it). The new charger has labelled 250 volts on it. France's voltage is seemingly 230 volts.

I am wondering what the 250 volts on the charger means. Does it mean all voltage going through it reaches 250? Does it handle a maximum of 250? Or is it simply capped at 250?

reddit.com
u/AyrtonHS — 3 days ago

Can I use the built-in emulator to use banking apps?

My real phone has some issues. I was wondering if it's safe to use the emulator to use banking apps. My main concern is security. I may install it to confirm purchases, and then immediately uninstall.

reddit.com
u/AyrtonHS — 4 days ago

Java is known for "write once, run anywhere", so why is Minecraft's Java version not the one that's shared accross the different platforms?

I am a computer science student and was taught both C++ and Java. I was told about Java's "Write once, run anywhere" slogan. If that's the case, why isn't Minecraft's Java edition the one that's shared across platforms? Why is it the C++ one?

reddit.com
u/AyrtonHS — 4 days ago

Thoughts on the video about International Schools by The Nation Thailand?

The title is "Why does Thailand need so many international schools? | The Signal Ep 23"

Link here: https://www.youtube.com/watch?v=_5jpUNR1p7g

It talks about how International schools are not only for expat children, but are also somewhat used to divide Thailand by wealth, where these schools are better and are attended by kids from rich families and even politicians.

u/AyrtonHS — 11 days ago

Do most European universities have a dual higher education system like WO and HBO in The Netherlands?

I learned about the dual system a year ago after a few years of doing a WO bachelor. I am now burnt out and don't want to continue with a master. I plan on going back to my home country in Asia where a WO bachelor will likely be seen as complete.

I wonder if other European countries have a similar system, research vs applied science universities, research bachelors considered incomplete, etc.

reddit.com
u/AyrtonHS — 21 days ago
▲ 2 r/Magisk

A few apps think I'm using a VPN after rooting with Magisk

I think it's Magisk that's the problem, as the messages occur even when I disable Lposed and XposedFakeLocation.

reddit.com
u/AyrtonHS — 24 days ago

Is my Variable Elimination implementation correct? Asking because different TAs marked them differently

I'm asking because it was deemed incorrect when I first submitted it. Due to time constraints, I decided to work on a different part of the big assignment and left it unchanged. In the resubmission, I had a different TA, and they ended up marking it right. My professor hasn't viewed it yet.

It uses Python Pandas.

The implementation:

import pandas as pd

def multiply(factor1, factor2):
    '''Factor multiplication
    Takes 2 factors and find the columns they have in common,
    combine rows whose common columns have the same values and multiply their probabilities'''

    def all_columns_equal(row1, row2, common_columns): 
        '''Helper function to see if all selected columns of 2 rows are the same'''

        for column in common_columns:
            if row1[column] != row2[column]:
                return False
        
        return True

    if factor1.empty:
        return factor2
    
    if factor2.empty:
        return factor1

    common_column = []

    f1_columns = factor1.columns.drop("prob")
    f2_columns = factor2.columns.drop("prob")

    #Find the common columns
    for f1_column in f1_columns:
        for f2_column in f2_columns:
            if f1_column == f2_column:
                common_column.append(f1_column)

    if common_column == []:
        return pd.DataFrame()

    entry = []
    
    for _, f1_row in factor1.iterrows():  
        for _, f2_row in factor2.iterrows():
            if all_columns_equal(f1_row, f2_row, common_column):

                series = [f1_row.drop("prob"), f2_row.drop(common_column).drop("prob"), pd.Series(f1_row["prob"]*f2_row["prob"], ["prob"])]
                new_row = pd.concat(series)
                entry.append(new_row)

    DataFrame = pd.DataFrame(data=entry)
    return DataFrame

def marginalization(factor, variable):

    factor_dropped_variable = factor.drop(columns=[variable]) # dataframe of factor without variable
    prob_column = factor.columns[-1] # probability column
    target_variables = factor_dropped_variable.drop(columns=[prob_column]).columns.tolist() # target variables to be summed

    if target_variables:

        marginalized_factor = factor_dropped_variable.groupby(target_variables, as_index=False).sum()

    else:

        marginalized_factor = pd.DataFrame()

    return marginalized_factor

def reduce(factor, reduced_column, value):

    entry = []

    for _, row in factor.iterrows():
        if row[reduced_column] == value:
            entry.append(row.drop(reduced_column))

    if (len(entry) == 1):
        return pd.DataFrame()

    DataFrame = pd.DataFrame(data=entry)
    return DataFrame

def maximization(factor, variable):

    factor_dropped_variable = factor.drop(columns=[variable]) # dataframe of factor without variable
    prob_column = factor.columns[-1] # probability column
    target_variables = factor_dropped_variable.drop(columns=[prob_column]).columns.tolist() # target variables to be summed

    if target_variables:
        maximized_factor = factor_dropped_variable.groupby(target_variables, as_index=False).max()

    else:
        maximized_factor = pd.DataFrame()

    return maximized_factor

part = 2

class VariableElimination():

    def __init__(self, network):
        """
        Initialize the variable elimination algorithm with the specified network.
        Add more initializations if necessary.

        """
        self.network = network

    def run(self, query, observed, elim_order):
        """
        Use the variable elimination algorithm to find out the probability
        distribution of the query variable given the observed variables

        Input:
            query:      A list of query variables
            observed:   A dictionary of the observed variables {variable: value}
            elim_order: Either a list specifying the elimination ordering
                        or a function that will determine an elimination ordering
                        given the network during the runb": [1,1,2,2], "c": [1,2,1,2], "prob": [0.5,0.7,0.1,0.2]

        Output: A variable holding the probability distribution
                for the query variable

        """

        file = open("log.txt", "w")

        file.write("Query variable: " + str(query) + "\n")
        file.write("Observed variable: " + str(observed) + "\n")

        for q in query: 
            
            if q in elim_order:
                elim_order.remove(q)


        file.write("Elimination ordering: " + str(elim_order) + "\n\n")

        factors = self.network.probabilities

        file.write("Starting factors: " + str(factors) + "\n\n")

        #Summing out observed variables
        for node in observed:

            if node in elim_order:
                elim_order.remove(node)
            
            for f in factors:
    
                if node in factors[f].columns:
                    factors[f] = reduce(factors[f],node,observed[node])

        file.write("Factors after reducing observed variables: " + str(factors) + "\n\n")

        #Eliminating all non-query and non-observed variables
        for variable in elim_order:

            product = pd.DataFrame()
            found = []

            for f in factors:
                if variable in factors[f]:
                    product = multiply(product,factors[f])
                    found.append(f)

            for f in found:
                factors.pop(f)

            new_factor = marginalization(product,variable)
            
            new_name = "*".join(found)
            factors[new_name] = new_factor

            file.write("Factors after eliminating " + variable + ": \n" + str(factors) + "\n\n")

        individual_factors = {}
        for q in query:

            temp_factors = factors.copy()

            remaining = query.copy()
            remaining.remove(q)

            for variable in remaining:

                product = pd.DataFrame()
                found = []

                for f in temp_factors:
                    if variable in temp_factors[f]:
                        product = multiply(product,temp_factors[f])
                        found.append(f)

                for f in found:
                    temp_factors.pop(f)

                new_factor = marginalization(product,variable)
                
                new_name = "*".join(found)
                temp_factors[new_name] = new_factor

                file.write("Factors after eliminating " + variable + ": \n" + str(factors) + "\n\n")

            product = pd.DataFrame()
    
            for f in temp_factors:
                product = multiply(product,temp_factors[f])

            sum = product.sum(0)["prob"]
            product["prob"] = product["prob"].div(sum)
            individual_factors[q] = product

        file.write("Individual factors:" + str(individual_factors))

        print("Result:\n")
        for f in individual_factors:
            print(individual_factors[f])

        file.close()

To run the file

from read_bayesnet import BayesNet
from variable_elim import VariableElimination

if __name__ == '__main__':
    # The class BayesNet represents a Bayesian network from a .bif file in several variables
    net = BayesNet('alarm.bif') # Format and other networks can be found on http://www.bnlearn.com/bnrepository/
    # These are the variables read from the network that should be used for variable elimination

    ve = VariableElimination(net)

    query = ['Alarm', 'Tampering']
 
    evidence ={'Leaving': 'True', 'Smoke': 'True'}

    elim_order = net.nodes

    ve.run(query, evidence, elim_order)

I tested the implementation by comparing my results with a published package, and the results matched, which is why I was confident it worked during the first submission.

During the initial feedback, "The individual functions appear to be working correctly, but along the way you end up with the incorrect solution. I expect the issue to lie in inconsistent factor representation/handling. I decided to subtract one point for this. -1 Also, empty dataframes are returned. " "Incorrect output for VE. -1 The individual steps appear to be okay, I'm not sure what is going on. To figure this out, a complete log can help with this. "

But then a new TA gave it full marks in the resubmission without any extra details, since there isn't much to say about a (supposedly) working implementation. I have already received the credits for this course. This is a rare instance at my uni where the professor doesn't grade assignments that decides if we pass the course.

Thank you.

u/AyrtonHS — 1 month ago

Bypassing geographical restriction

I am temporarily staying at a country where Skillz pro tournaments are not available, even ones with free entry but cash prizes.

I've already tried to spoof my gps and use a VPN (both at once) but skillz still detects my real location. I was able to trick a different app so I'm sure it's not the method's problem but skillz being good.

Has anyone managed to bypass? Thank you.

reddit.com
u/AyrtonHS — 1 month ago

Is my Variable Elimination implementation correct

I'm asking because it was deemed incorrect when I first submitted it. Due to time constraints, I decided to work on a different part of the big assignment and left it unchanged. In the resubmission, I had a different TA, and they ended up marking it right. My professor hasn't marked it yet.

It uses Python Pandas.

The implementation:

import pandas as pd


def multiply(factor1, factor2):
    '''Factor multiplication
    Takes 2 factors and find the columns they have in common,
    combine rows whose common columns have the same values and multiply their probabilities'''

    def all_columns_equal(row1, row2, common_columns): 
        '''Helper function to see if all selected columns of 2 rows are the same'''

        for column in common_columns:
            if row1[column] != row2[column]:
                return False
        
        return True

    if factor1.empty:
        return factor2
    
    if factor2.empty:
        return factor1

    common_column = []

    f1_columns = factor1.columns.drop("prob")
    f2_columns = factor2.columns.drop("prob")

    #Find the common columns
    for f1_column in f1_columns:
        for f2_column in f2_columns:
            if f1_column == f2_column:
                common_column.append(f1_column)

    if common_column == []:
        return pd.DataFrame()

    entry = []
    
    for _, f1_row in factor1.iterrows():  
        for _, f2_row in factor2.iterrows():
            if all_columns_equal(f1_row, f2_row, common_column):

                series = [f1_row.drop("prob"), f2_row.drop(common_column).drop("prob"), pd.Series(f1_row["prob"]*f2_row["prob"], ["prob"])]
                new_row = pd.concat(series)
                entry.append(new_row)

    DataFrame = pd.DataFrame(data=entry)
    return DataFrame

def marginalization(factor, variable):

    factor_dropped_variable = factor.drop(columns=[variable]) # dataframe of factor without variable
    prob_column = factor.columns[-1] # probability column
    target_variables = factor_dropped_variable.drop(columns=[prob_column]).columns.tolist() # target variables to be summed

    if target_variables:

        marginalized_factor = factor_dropped_variable.groupby(target_variables, as_index=False).sum()

    else:

        marginalized_factor = pd.DataFrame()

    return marginalized_factor

def reduce(factor, reduced_column, value):

    entry = []

    for _, row in factor.iterrows():
        if row[reduced_column] == value:
            entry.append(row.drop(reduced_column))

    if (len(entry) == 1):
        return pd.DataFrame()

    DataFrame = pd.DataFrame(data=entry)
    return DataFrame

def maximization(factor, variable):

    factor_dropped_variable = factor.drop(columns=[variable]) # dataframe of factor without variable
    prob_column = factor.columns[-1] # probability column
    target_variables = factor_dropped_variable.drop(columns=[prob_column]).columns.tolist() # target variables to be summed

    if target_variables:
        maximized_factor = factor_dropped_variable.groupby(target_variables, as_index=False).max()

    else:
        maximized_factor = pd.DataFrame()

    return maximized_factor

part = 2

class VariableElimination():


    def __init__(self, network):
        """
        Initialize the variable elimination algorithm with the specified network.
        Add more initializations if necessary.


        """
        self.network = network

    def run(self, query, observed, elim_order):
        """
        Use the variable elimination algorithm to find out the probability
        distribution of the query variable given the observed variables


        Input:
            query:      A list of query variables
            observed:   A dictionary of the observed variables {variable: value}
            elim_order: Either a list specifying the elimination ordering
                        or a function that will determine an elimination ordering
                        given the network during the runb": [1,1,2,2], "c": [1,2,1,2], "prob": [0.5,0.7,0.1,0.2]

        Output: A variable holding the probability distribution
                for the query variable

        """

        file = open("log.txt", "w")

        file.write("Query variable: " + str(query) + "\n")
        file.write("Observed variable: " + str(observed) + "\n")

        for q in query: 
            
            if q in elim_order:
                elim_order.remove(q)

        file.write("Elimination ordering: " + str(elim_order) + "\n\n")

        factors = self.network.probabilities

        file.write("Starting factors: " + str(factors) + "\n\n")

        #Summing out observed variables
        for node in observed:


            if node in elim_order:
                elim_order.remove(node)
            
            for f in factors:
    
                if node in factors[f].columns:
                    factors[f] = reduce(factors[f],node,observed[node])


        file.write("Factors after reducing observed variables: " + str(factors) + "\n\n")


        #Eliminating all non-query and non-observed variables
        for variable in elim_order:

            product = pd.DataFrame()
            found = []

            for f in factors:
                if variable in factors[f]:
                    product = multiply(product,factors[f])
                    found.append(f)

            for f in found:
                factors.pop(f)


            new_factor = marginalization(product,variable)
            
            new_name = "*".join(found)
            factors[new_name] = new_factor


            file.write("Factors after eliminating " + variable + ": \n" + str(factors) + "\n\n")

        if part == 1:

            individual_factors = {} #New variable as we will use the old factors dict for MAP
            for q in query:

                temp_factors = factors.copy()

                remaining = query.copy()
                remaining.remove(q)

                for variable in remaining:

                    product = pd.DataFrame()
                    found = []

                    for f in temp_factors:
                        if variable in temp_factors[f]:
                            product = multiply(product,temp_factors[f])
                            found.append(f)

                    for f in found:
                        temp_factors.pop(f)

                    new_factor = marginalization(product,variable)
                    
                    new_name = "*".join(found)
                    temp_factors[new_name] = new_factor

                    file.write("Factors after eliminating " + variable + ": \n" + str(factors) + "\n\n")

                product = pd.DataFrame()
        
                for f in temp_factors:
                    product = multiply(product,temp_factors[f])

                sum = product.sum(0)["prob"]
                product["prob"] = product["prob"].div(sum)
                individual_factors[q] = product

            file.write("Individual factors:" + str(individual_factors))


            print("Result:\n")
            for f in individual_factors:
                print(individual_factors[f])


        #Here onwards is the MAP extension of variable elimination

        if part == 2:

            print("factors after VE")

            for f in factors:
                print(f)
                print(factors[f])

            print("\n")


            yfactors = {} #Called y like the slides, couldn't think of a better name
            for variable in query:

                product = pd.DataFrame()
                found = []

                for f in factors:
                    if variable in factors[f]:
                        print(variable, "found in", f)
                        product = multiply(product, factors[f])
                        found.append(f)

                for f in found:
                    factors.pop(f)

                new_factor = maximization(product, variable)

                file.write("Factors after eliminating " + variable + ": \n" + str(factors) + "\n\n")

                new_name = "*".join(found)
                print(new_name)
                factors[new_name] = new_factor
                yfactors[variable] = product #Keep track of the premaxed factors

            print("results: ")

            for f in yfactors:
                print(yfactors[f])

            query.reverse()

            for variable in query:

                current_factor = yfactors[variable]
                current_factor = current_factor.set_index(current_factor.columns[0]) #We know there is just one column
                max_index = current_factor["prob"].argmax()

                print("Maximum for", variable, ":",  current_factor.index[max_index])

                for f in yfactors:
                    if variable in yfactors[f]:
                        yfactors[f] = reduce(yfactors[f], variable, current_factor.index[max_index])

        file.close()

To run the file

net = BayesNet('munin.bif') # Format and other networks can be found on http://www.bnlearn.com/bnrepository/
    # These are the variables read from the network that should be used for variable elimination


    ve = VariableElimination(net)


    query = ['R_MEDD2_CV_EW', 'R_LNLW_MEDD2_BLOCK_WD']
 
    evidence ={'R_MEDD2_AMP_WD': 'UV1_77', 'R_MEDD2_LSLOW_WD': 'MOD'}


    elim_order = net.nodes

    ve.run(query, evidence, elim_order)

I tested the implementation by comparing my results with a published package, and the results matched, which is why I was confident it worked during the first submission.

Also, part 1 is normal variable elimination, while part 2 is with MAP queries.

Thank you.

reddit.com
u/AyrtonHS — 1 month ago

I plan on burning a lot of bridges over anger in being 3rd culture kids

My last post: https://www.reddit.com/r/TCK/comments/1rf0c4m/goodbye_uk/

So when I brought this up in a group chat with my former classmates who also grew up as 3rd culture kids, I received backlash. What stood out to me were 2 people, I'll call them Nathan and Ralph.

Nathan said

>the grass isn’t greener on the other side, it’s greener where you water it

Ralph said

>Ayrton how many passports do you have and what are they?

>If you list one in an eu country I am going to fucking lose my shit.

>Because I swear youre French and can get into any EU country without a visa. And like tens of

>fucking countries have so many options for english jobs.

>Its absolutely crazy how broken being an EU citizen is. The opportunities are fucking crazy and almost endless. Not literally and that is an exaggeration but you need to be realistic. English opens so many doors and you do know the language. You aren't worse off for options just because you went to an international school.

>You are only specifically worse off for going back to Taiwan and getting a specific job that requires mandarin which you are wayyyy too focused on only because thats the only way you can prove your point.

>Stop trying to justify yourself and open yourself to the truth. Jobs are hard to get yes thats true. Because there are lots of people applying and its not always easy to find the right fit.

>But that doesn't mean that it isnt out there. It is and you have the possibility of taking up those positions with your current capabilities without having to change anything.

>I will no longer involve myself in any of this conversation because I believe there is no more i can say in no other way to make it more clear than I already have.

>For the last time now, I wish you the best

Here's the thing. Nathan has an American passport and has worked in America, so he has no problems with language and citizenship. He then still went out of his way to study in the UK because his family could afford it while mine couldn't.

Ralph is worse. He also went to study in the UK, and he's also the son of the principal of that British school, meaning there's an obvious conflict of interest when he defends the system. The last nail in the coffin is that he got a job at the same school we grew up in, so I can throw in nepotism. Note: he wrote this aggressive response in front of the entire group chat, while I was mostly just bringing up concerns without attacking anyone.

Here is a response I've drafted.

>You know, I thought of this comeback shortly after, but really wondered if I wanted to burn so many bridges. After thinking for months, I figured if the bridges all lead to trash, then I might as well burn them for warmth.

>Ralph, you're a fucking hypocrite. You gloat about EU passports while having a French passport yourself, yet chose to study in the UK, a country where English is the main language. Being the son of HS's CEO, there is a clear conflict on interest, of course you're fine with this system, the one that made your family rich and allow you to live a luxurious life, the same system that scammed my parents. Yep, I'm calling it a scam. Someone said we were privileged to attend a private school with high fees. Well guess what? Scientology is expensive; illegal drugs are expensive; it doesn't mean they're good. Your parents scamming mine is also why they could send you to study in the UK.

>No more mister nice guy. I was being kind, respectfully listing concrete facts, and you drop this shit. I genuinely think I can call your dad a scammer and still be the lesser of 2 evils. I love my parents and I think they're victims to your family's scheme. As a last resort I would've prefer if they sent me to a thai school, cheaper, and I get to see Thailand as a home, not to mention not meeting you. My parents are then forced to pay even more money, as studying abroad became my only choice. So yeah, they were scammed both directly and indirectly by your family. I *will* give you credit for moving back to Thailand, meaning you are now in a country where English isn't too common, but since you work at HS, I can throw in nepotism. Bold of you to talk about getting jobs when yours was given to you.

>Nathan, you fucking dare to downplay my language concerns when you're fucking American AND you still went out of your way to waste your Dad's money in order to study in the UK, 2 privileges I do not have. Grass is greener where you water it, you say? Well you have 2 gardens that are already watered for you.

>You 2 are the only ones I would name. Then in general. I split us into 3 groups.

>Rich: People with citizenship to English countries or can afford to immigrate them, so Reece and Nick.
Middle-class: EU citizens like me
Poor: everyone else

>Yes I have it slightly better than average. However, my biggest frustration is when people say I have an EU passport so I shouldn't be mad. *HS didn't give me my EU passport*, it's something I already had; HS just made it less useful (than if I grew up in France). It's like if someone broke my leg, and people say I shouldn't be mad because I have health insurance. My EU passport partially saved me from HS's poison, but only partially, and it became weaker in the process. The way I see it, all my arguments were objective and concrete. There are jobs we would likely never be able to hold like Firefighters, Police, many degrees, and many trades. Everyone else gave abstract arguments. Boasting about knowing English, but I don't see them actually applying it.

>International schools don't guarantee failure, but it provides almost nothing more, leads to a lot more risk with little gain. Being pessimistic is beneficial in that I'm either wrong or happily incorrect, but I honestly would be more happy to see all the Thai students struggle in life due to their weakened Thai than to succeed, especially after how they dismissed me.

>Also someone said I'm blaming anyone. No, even if you think I'm extreme, it makes PERFECT sense to blame cambridge, they're the ones behind this, the top of the latter, the rich corporation that benefits the most from this. Blaming anyone would be blaming Jake Paul or something. I wanted to put all beef aside for this, but after it, I remembered; many of you were assholes to me. Was I problematic? Probably, but I'm still mad about that meme account that allowed everyone to join except me, because there were 2 memes that made fun of me. I fucking hate you all. I won't ruin my life for this yet, but if I had the opporunity, I would destroy all International schools. If I ever miraculously became an influencer, I would spend all my time shit talking International schools.

>TL;DR Ralph is a hypocrite, benefits from the system, and also benefits from nepotism.
Nathan is like a rich person telling a poor person that being poor isn't bad, while he was born rich.
Everyone else is fucking stupid and I hate you all

I haven't posted it yet, but I'm leaning towards posting it. I would like more feedback before I make this decision.

reddit.com
u/AyrtonHS — 1 month ago

Things to order on Bol

Last year, I had accidentally signed up for a year of Bol Select. While I ordered a few things, I want to order a bit more before it expires in around 2 weeks.

What items are either exclusive to Bol or cheaper when ordered from Bol as opposed to local supermarkets?

Thank you

reddit.com
u/AyrtonHS — 2 months ago

Is the birthday paradox relevant here?

Here is an exam question from my professor who chose not to give the mark scheme.

The stream cipher works as follows. It takes a 64-bit key, an 8-bit encoding of the date, and
an 8-bit diversifier. Then, it generates a keystream of sufficient length, which gets added to the
plaintext to get a ciphertext. Per day, no diversifier occurs more than once (but diversifiers may
repeat across different days).

c) (2pt) Suppose you generate diversifiers uniformly at random. Estimate the probability of
plaintext information leakage with respect to an adversary that can observe two ciphertex-
t/diversifier pairs on a single day.

(d) (1pt) Suppose you generate diversifiers uniformly at random. Estimate the probability of
plaintext information leakage with respect to an adversary that can observe ten ciphertex-
t/diversifier pairs on a single day

I shamefully admit to asking Chatgpt for a markscheme.

>
(c): 2 observations → NO birthday paradox needed

>Here you have:

>sample size = 2

>space size = 28=2562^8 = 25628=256

>So you compute the exact collision probability:

>P(collision)=1256=2−8P(\text{collision}) = \frac{1}{256} = 2^{-8}P(collision)=2561​=2−8

>This is just a direct probability of equality of two random draws.

>👉 No “asymptotic collision phenomenon” needed.

>

>(d): 10 observations → YES, birthday reasoning becomes relevant

>Now you have:

>sample size = 10

>space size = 256

>Here you don’t want to compute all pairwise cases directly, so you use the birthday approximation:

>P(collision)≈1−e−10⋅92⋅256P(\text{collision}) \approx 1 - e^{-\frac{10\cdot 9}{2 \cdot 256}}P(collision)≈1−e−2⋅25610⋅9​

>or simplified:

>≈1022⋅256≈0.2\approx \frac{10^2}{2 \cdot 256} \approx 0.2≈2⋅256102​≈0.2

>This is exactly where the birthday effect starts to matter.

So ChatGPTt is saying that c doesn't use the birthday paradox due to the smaller sample size, while d does. I expect both to involve the birthday paradox. Is ChatGPT wrong? I admit I don't understand its reasoning.

reddit.com
u/AyrtonHS — 2 months ago
▲ 3 r/django

Would a one-to-many field make things easier?

Disclaimer: I already found a way to make the database structure work, I just curious about this concept and if it would make sense to exist.

So in our project, every Team of people has an Account that stores their points. Originally, every team has one account and vice versa, so I just used a OneToOne Field. For convenience, Accounts can be automatically created when a Team is created if the admin doesn't make an account in advance. Originally there was no problem. The Team Model file imports the Account Model to both u

In Team's model (simplified for privacy issues):

import Account

account = models.OneToOneField(Account)

def save(self, *args, **kwargs):

account = Account(name=self.name + " points")

account.save()

self.account = account

Meanwhile, Account never imports Team, so things were fine.

However, I reread the requirements and noticed that the client wants each team to have multiple accounts, but each account can only belong to one team.

Since one-to-many doesn't really exist, I assume the best way is to define a ForeignKey in Account to point to Team:

import Team

team = models.ForeignKey(Team)

Here's the problem. We still import Account in Team in order to create the accounts for the teams, since the teams need the accounts (it needs at least one, and it is required to have a certain number of accounts based on conditions). This leads to circular import.

Now the problem has already been fixed using Lazy relationships, but I wonder: if there was a one-to-many field, would I be able to connect to Account in Team and therefore only import Account in Team and not vice versa? This is embarrassing, but I first asked Chatgpt and it kept telling me that it's not how it works. Thank you.

reddit.com
u/AyrtonHS — 3 months ago
▲ 3 r/django

A team has 2 accounts. We represent these 2 accounts with the same model. Both of these accounts should be used by only one team. I used forms.OneToOneFieldin an attempt to apply the one-account restriction. It only partially works. Django allows team 1 to use account a as its first account and team 2 to use the same account a as its second account. I wonder if anyone has encountered something similar and is able to apply a stricter constraint where an account can only be used a single time.

reddit.com
u/AyrtonHS — 3 months ago
▲ 8 r/django

I was just wondering why Rest Framework has its own Authentication and Permission features. Do we have to use these when working with Rest Framework?

reddit.com
u/AyrtonHS — 4 months ago