예제 #1
0
def getPoint(maxL=10):
    type_dist = "loguniform"

    RStarSample = sample_value(
        0, 2,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fPlanets = sample_value(
        -1, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    nEnvironment = sample_value(
        -1, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fIntelligence = sample_value(
        -3, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fCivilization = sample_value(
        -2, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    L = sample_value(
        2, maxL,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fLife = lifeDist(mean=0, sigma=50)
    fLifeEks = float(mp.log(fLife, 10))

    nStars = random.uniform(11, 11.60205999132)
    E3 = nStars + fPlanets + nEnvironment
    E4 = E3 + fLife
    E5 = E4 + fIntelligence

    resitev = RStarSample + fPlanets + nEnvironment + fLifeEks + fIntelligence + fCivilization + L  # calculates N

    # thresholds
    # rand_tresh = 4
    # if random.random()<0.5:
    rand_tresh = 3
    glajenje = 0.2
    '''
    if (E4 < np.random.normal(math.log(2, 10), glajenje) \
            or E3 < np.random.normal(math.log(3, 10), glajenje) \
            or resitev > np.random.normal(3.5, glajenje)
            or resitev < np.random.normal(-3, glajenje)):
        # return getPoint(maxL)
        return False
    '''

    if resitev < -6:
        return False
    return 10**resitev
예제 #2
0
def getPoint(maxN=10):
    dist = "uniform"
    RStarSample = sample_value(0, 2, dist)  # logaritmic
    Nstar = 11.4771212547  # total number of stars. Paper persumes there are 2*10^22 oz. 22.30103  in our observable universe - only for our galaxy 3*10^11 oz. 11.4771212547
    fPlanets = sample_value(
        -1, 0, dist)  # paper suggests 1           np.random.normal(1)
    nEnvironment = sample_value(
        -1, 0, dist)  # paper suggests 0.2    np.random.normal(0.2)
    astrophysicsProbability2 = np.random.normal(
        0.155, 0.73
    )  # distributuin that is similar to the one if we calculate it our self
    if (astrophysicsProbability2 >
            2):  # so that the distribution look more similar
        astrophysicsProbability2 = sample_value(1.65, 1.95, dist)
    if (astrophysicsProbability2 < -2):
        astrophysicsProbability2 = sample_value(-1.95, -1.65, dist)

    fInteligence = sample_value(-3, 0, dist)
    fCivilization = sample_value(-2, 0,
                                 dist)  # in the paper it is mentioned as ft
    fLife = lifeDist(mean=0, sigma=50)
    fLifeEks = float(mp.log(fLife, 10))

    # L = random.uniform(2, maxL)     #loguniform
    # L = math.log10(sample_value(10 ** 2, 10 ** maxL, dist))  # uniform
    N = sample_value(0, maxN, dist)

    # biotechnicalProbability  - lower bound calcuclated to be 2.5*10^-24   aka -23.60206 - only for our galaxy 	1.7*10^-11 aka -10.76955

    # astrophysicsProbability = RStarSample + fPlanets + nEnvironment  # use Nstar instead of rstarsample if no L
    # biotechnicalProbability = fInteligence + fCivilization + fLifeEks
    biotechnicalProbability = sample_value(-10.76955, 0, dist)

    # resitev = astrophysicsProbability + biotechnicalProbability   #calculates A = number of civ that have ever apperared in the world
    resitev = N - (
        astrophysicsProbability2 + biotechnicalProbability
    )  # calculates A = number of civ that have ever apperared in the world

    E3 = Nstar + fPlanets + nEnvironment
    E4 = E3 + fLife
    # E5 = E4 + fInteligence

    # threshold if N values are very low
    # if (resitev < 0):       #treshold from min possible solution
    # if (resitev < 0) or (resitev > 5):       #threshold min and L possible solution
    glajenje = 0.4
    if resitev < np.random.normal(0, glajenje) or resitev > np.random.normal(
            5, glajenje):  # bokal?
        return False

    # x.append(astrophysicsProbability) #from our distribution calculated distribution
    # y.append(astrophysicsProbability2)  #from our distribution
    return resitev
예제 #3
0
def getPoint(maxN=10):
    type_dist = "loguniform"

    RStarSample = sample_value(0, 2, type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fPlanets = sample_value(-1, 0, type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    nEnvironment = sample_value(-1, 0, type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fIntelligence = sample_value(-3, 0, type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fCivilization = sample_value(-2, 0, type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    # N = sample_value(0, maxN, type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    N = np.log10(maxN)
    #N = maxN
    fLife = lifeDist(mean=0, sigma=50)
    fLifeEks = float(mp.log(fLife, 10))

    nStars = random.uniform(11, 11.60205999132)
    E3 = nStars + fPlanets + nEnvironment
    E4 = E3 + fLife
    E5 = E4 + fIntelligence

    # resitev = RStarSample + fPlanets + nEnvironment + fLifeEks + fInteligence + fCivilization + L
    L = N - (RStarSample + fPlanets + nEnvironment + fLifeEks + fIntelligence + fCivilization)

    glajenje = 0.4

    # thresholds
    # if (L < np.random.normal(0, glajenje)
    '''
    if (E4 < np.random.normal(math.log(2, 10), glajenje)
            or E3 < np.random.normal(math.log(3, 10), glajenje)
            or L > np.random.normal(10.139879,
                                    glajenje)):  # maxL - age of the universe - if we are taking drake equation for this moment
        # return getPoint(maxN)
        return False
    '''
    return L
def getPoint(maxL=10, type_dist="loguniform"):
    RStarSample = sample_value(
        0, 2,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fPlanets = sample_value(
        -1, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    nEnvironment = sample_value(
        -1, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fIntelligence = sample_value(
        -3, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fCivilization = sample_value(
        -2, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    L = sample_value(
        2, maxL,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fLife = lifeDist(mean=0, sigma=50)
    fLifeEks = float(mp.log(fLife, 10))
    # fLifeEks = np.random.lognormal(-2 , 0)

    resitev = RStarSample + fPlanets + nEnvironment + fLifeEks + fIntelligence + fCivilization + L  # calculates N

    # threshold if N values are very low
    # if (resitev < 0):
    #    return False

    resitev1 = 10**resitev  # rounded de-logarithmised solution

    # for i in range(resitev1):
    # A = abs(random.gauss(1, 0.2))
    A = 1
    v = abs(random.gauss(0.016 * 300000, 10)) * 365 * 24 * 60 * 60
    # L1 = random.uniform(2, maxL)
    L1 = 10**L
    B = 0.004 / (
        (9.461 * 10**(12))**3)  # number density of stars as per Wikipedia
    R = v * random.uniform(
        0, L1
    )  # radius of inhabited zone, I assume they have been expanding since the became detectable, which is random
    # integral = integrate.quad(lambda r: r ** 2 * math.exp(-(R - r) / (v * 10 ** L1)), 0, R)
    integral = L1 * v * (R**2 - 2 * L1 * R * v + 2 *
                         (1 - math.e**(-R / (L1 * v))) * L1**2 * v**2)

    n = B * 10**fPlanets * 10**nEnvironment * 4 * math.pi * integral

    koncnaResitev0 = A * (n + 1) * resitev1

    if koncnaResitev0 < 0:
        return False, False

    koncnaResitev1 = math.log10(koncnaResitev0)

    # print('n ',n,' integral ',integral,' resitev1', resitev1,'resitev', resitev,' koncnaResitev0 ',koncnaResitev0,' koncnaResitev1 ',koncnaResitev1)

    glajenje = 0.2
    nStars = random.uniform(11, 11.60205999132)
    E3 = nStars + fPlanets + nEnvironment
    E4 = E3 + fLife

    #if koncnaResitev1 < np.random.normal(0, glajenje) or koncnaResitev1 > np.random.normal(4, glajenje):
    '''
    if E4 < np.random.normal(math.log(2, 10), glajenje) \
            or E3 < np.random.normal(math.log(3, 10), glajenje) \
            or koncnaResitev1 < -6 :
            #or koncnaResitev1 > np.random.normal(3.5, glajenje):
        return False, False

    # if koncnaResitev1 < -6 or koncnaResitev1 > np.random.normal(3.5, glajenje):
    #     return False
    if koncnaResitev1 > nStars:
        return False, False
    '''
    return koncnaResitev1, koncnaResitev0 / resitev1
예제 #5
0
def getPoint(maxN=10, type_dist="loguniform"):
    RStarSample = sample_value(
        0, 2,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fPlanets = sample_value(
        -1, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    nEnvironment = sample_value(
        -1, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fIntelligence = sample_value(
        -3, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fCivilization = sample_value(
        -2, 0,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    N = 10**sample_value(
        0, maxN,
        type_dist)  # loguniform - uniform - halfgauss - lognormal - fixed

    fLife = float(lifeDist(mean=0, sigma=50))
    fLifeEks = float(mp.log(fLife, 10))

    f = 10**(RStarSample + fPlanets + nEnvironment + fLifeEks + fIntelligence +
             fCivilization)

    nStars = random.uniform(11, 11.60205999132)
    E3 = nStars + fPlanets + nEnvironment
    E4 = E3 + fLife
    meje = RStarSample + fPlanets + nEnvironment + fLifeEks + fIntelligence + fCivilization + 10
    #if E4 < 2 or E3 < 3 or meje < 0:
    #   return False

    # A = abs(random.gauss(1, 0.2))
    A = 1
    v = abs(random.gauss(0.016 * 300000, 10)) * 365 * 24 * 60 * 60
    ############################################################################# TODO
    # R = v * random.uniform(0, L)  # radius of inhabited zone, I assume they have been expanding since the became detectable, which is random
    # ok tle ^ not je dejansko tudi L, nisem tega vidu prej... to je treba se nekako vkljucit
    # bom dal V*L/2

    # Tle je enacba more bit 0 na eni strani in vse ostalo na drugi
    # function = lambda L: 1 / nStars * f * A * L * (L * v * (R ** 2 - 2 * L * R * v + 2 * L ^ 2 * v ^ 2 * (1 - mp.e ** (-R / (L * v))))) - N

    B = 0.004 / (
        (9.461 * 10**(12))**3)  # number density of stars as per Wikipedia
    function = lambda L: f * A * L * (
        B * 10**fPlanets * 10**nEnvironment * 4 * math.pi *
        (L * v * ((v * L / 2)**2 - 2 * L *
                  (v * L / 2) * v + 2 * L**2 * v**2 * 0.393469)) + 1) - N
    function1 = lambda L: f * A * (L + 5.13342 * 10**10 * 10**
                                   (fPlanets + nEnvironment) * B * L**4) - N
    L_initial_guess = 10**2  # to je se za malo probat
    L_solution, info, ier, mes = fsolve(function1,
                                        L_initial_guess,
                                        full_output=1)  # numerical solver
    # print(np.log10(L_solution[0]), ' sol ', L_solution, ' info ', info, ' ier ', ier, ' mes ', mes)
    if ier != 1:
        return False
    #    print(np.log10(L_solution[0]), ' sol ', L_solution, ' ier ', ier, ' f ', f)
    L = math.log(L_solution[0], 10)
    #if (L < 0) or E4 < math.log(2, 10) or E3 < math.log(3, 10) or L > 10.139879:  # maxL - age of the universe
    #     return False

    return L