Beispiel #1
0
def test_compare_scipy_Lognormal():

    shape = 3.0

    dist_cp = cp.Lognormal(mu=0.0, sigma=shape, scale=1.0, shift=0)
    r0, r1 = dist_cp.range()
    x = np.linspace(r0, r1, 300, endpoint=True)

    pdf_sp = stats.lognorm.pdf(x, shape, scale=1.0, loc=0)
    cdf_sp = stats.lognorm.cdf(x, shape, scale=1.0, loc=0)

    np.testing.assert_allclose(pdf_sp, dist_cp.pdf(x))
    np.testing.assert_allclose(cdf_sp, dist_cp.cdf(x))
Beispiel #2
0
import chaospy as cp
from ProblemSettings import *

parameters['allow_extrapolation'] = True
parameters["form_compiler"]["quadrature_degree"] = 4
parameters["form_compiler"]["cpp_optimize"] = True
parameters["form_compiler"]["representation"] = "uflacs"

timer = Timer("00: forward run")
model = problem()

# Define random distribution for each parameter
b_ff_dist = cp.Normal(mu=6.6, sigma=0.99)
b_xx_dist = cp.Normal(mu=4.0, sigma=0.6)
b_fx_dist = cp.Normal(mu=2.6, sigma=0.39)
CC_dist = cp.Lognormal(
    mu=-0.049, sigma=0.538)  #cp.Normal(mu = 1.1 , sigma = 0.165)      #kPa
K_dist = cp.Lognormal(
    mu=2.2964, sigma=0.11)  #cp.Normal( mu = 10.0, sigma = 1.5)           #kPa
fiber_rotation_epi_dist = cp.Normal(mu=50, sigma=7.5)  #deg
fiber_rotation_end_dist = cp.Normal(mu=40, sigma=6.0)  #deg
sheet_rotation_epi_dist = cp.Normal(mu=65, sigma=9.75)  #deg
sheet_rotation_end_dist = cp.Normal(mu=25, sigma=3.75)  #deg

print('Calling Chaospy')

# Define Joint probability density funtion
#joint = cp.J(b_ff_dist,b_xx_dist,b_fx_dist,CC_dist,K_dist,fiber_rotation_epi_dist)
joint = cp.J(b_ff_dist, b_xx_dist, b_fx_dist, CC_dist, K_dist,
             fiber_rotation_epi_dist, fiber_rotation_end_dist,
             sheet_rotation_epi_dist, sheet_rotation_end_dist)
import numpy as np
import matplotlib.pyplot as plt

# === The useful help function ===
# show help for uniform distributions
cp.Uniform?

# show help for sample generation
cp.samplegen?
# end help

# === Distributions ===
# simple distributions
rv1 = cp.Uniform(0, 1)
rv2 = cp.Normal(0, 1)
rv3 = cp.Lognormal(0, 1, 0.2, 0.8)
print(rv1, rv2, rv3)
# end simple distributions

# joint distributions
joint_distribution = cp.J(rv1, rv2, rv3)
print(joint_distribution)
# end joint distributions

# creating iid variables
X = cp.Normal()
Y = cp.Iid(X, 4)
print(Y)
# end creating iid variables

# === Sampling ===