Search code examples
pythonequalitycomparison-operators

How can I express much greater than in Python


I need to compare two values for an if statement with the greater than equality.

        if delta_t > tao_threshhold:
            n = np.random.normal(0, 1)  
            rxn_vector = propensity*delta_t + (propensity*delta_t)**0.5*n 
            new_popul_num = popul_num

but I need the equality to be for much greater than. In maths the notation used is >> but this means something completely different in Python syntax.

Is there a way to express this much greater than equality in Python?

Cheers


Solution

  • As everyone is pointing out "much greater" is not a well-defined concept in mathematics/science. It is used in theoretical work to demonstrate concepts but it is open to interpretation when trying to implement the mathematical models in code.

    That being said, "much greater" is often understood as "some orders of magnitudes greater" but exaclty how many is more or less up to you to define using intuition and experiments. It is also highly dependent on the units of measurement and the scaling of compared values (e.g. is there an upper bound delta_t? what values do you consider "much greater" and what values you do not? Do you have a prior knowledge or hint on how its values are distributed depending on different parameters of your algorithm?)

    Practically, a way to treat it is the following:

    1. Define some order of magniutde quantity:
    E = 10e3
    
    1. Implement your if statement as:
    if delta_t > E*tao_threshold:
        ...
    
    1. Be aware of precision errors: multiplying large numbers together is not safe.
    2. If you are not sure how to choose approprite E values, you can start with the following principal:
      Intuitively, your algorithm should not depend on E. So, for a given set of parameters and a chosen E value, (if your algorithm is deterministic or proven to converge to a specific value within the chosen parameters), your algorithm should show the same results for nearby E's. So you can explore different ranges of E for different sets of parameter values and search for stabilization regions. Assuming you have a scalar output and less than 3 parameters, this can be done by plotting the output. Just a point here: This is not the same as an optimization search. You want to find E values that lead to "stable" results, not "best" results.
    3. Document everything in the code, README, documentation site, and potential technical paper. Allow the user of the code to change the selected value if needed.
    4. Considering that tao_threshold looks like a parameter, it may be simpler just to explore different scales in that variable rather than introducing a "much greater" quantifier. But this greatly depends on the context of your algorithm and it may reduce that parameter's interpretability.