コード例 #1
0
ファイル: simple_mc_2d.py プロジェクト: vlarson/class-scripts
def drawNormalLognormalPoints(numSamples,muN,sigmaN,muLNn,sigmaLNn,rhon):
    """Return sample points from a non-standard normal-lognormal PDF."""

    from mc_utilities import drawStdNormalPoints
    from numpy import zeros, exp, dot, copy
    from numpy.linalg import cholesky

    stdNormalPoints = zeros((numSamples,2))
    
    stdNormalPoints[:,0] = drawStdNormalPoints(numSamples)
    stdNormalPoints[:,1] = drawStdNormalPoints(numSamples)

    covarMatn = [  [sigmaN**2,            rhon*sigmaN*sigmaLNn],
                   [rhon*sigmaN*sigmaLNn,   sigmaLNn**2]
                ]

    LCholesky = cholesky(covarMatn)

#    normalPoints = dot(stdNormalPoints, LCholesky) + [muN, muLNn]
    normalPoints = dot(stdNormalPoints, LCholesky.T) + [muN, muLNn]

#    pdb.set_trace()

    normalLognormalPoints = copy(normalPoints)
    normalLognormalPoints[:,1] = exp(normalLognormalPoints[:,1])

    return normalLognormalPoints
コード例 #2
0
ファイル: simple_mc_1d.py プロジェクト: vlarson/class-scripts
def drawNormalPoints(numSamples,mu,sigma):
    from mc_utilities import drawStdNormalPoints

    StdNormalPoints = drawStdNormalPoints(numSamples)

    return mu + sigma*StdNormalPoints