File:Ito lemma 1D illustration.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 576 × 432 pixels, file size: 126 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Desc

    Python

    import numpy as np
    import matplotlib.pyplot as plt
    from scipy.stats import norm
    
    def f(x):
      return (x-1)**2 + 1*(x-1)+0.5
    
    mean = 1
    xs = np.random.normal(mean, 0.1, 2000)
    ys = f(xs)
    
    for x, y in zip(xs[:200], ys[:200]):
        plt.plot([x, x], [0, y], 'g', alpha=0.1)
        plt.plot([0, x], [y, y], 'g', alpha=0.1)
    
    plt.plot([mean, mean], [0, f(mean)], 'r')
    plt.plot([0, mean], [f(mean), f(mean)], 'r')
    
    x_values = np.linspace(0, 1.2, 100)
    plt.plot(x_values, f(x_values), label=r'f', color='b')
    
    plt.xlabel(r'$X_{t+dt} = X_t + \mu_t dt + z\sigma_t\sqrt{dt}}})
    plt.ylabel(r'$f(X_{t+dt})}})
    
    params_x = norm.fit(xs)
    params_y = norm.fit(ys)
    
    # Create Gaussian distributions for xs and ys
    x_dist = norm(loc=params_x[0], scale=params_x[1])
    y_dist = norm(loc=params_y[0], scale=params_y[1])
    
    # Plot the Gaussian distribution over xs as (x, rho_x(x))
    x_values = np.linspace(x_dist.mean() - 3*x_dist.std(), x_dist.mean() + 3*x_dist.std(), 100)
    rho_x = x_dist.pdf(x_values)
    plt.plot(x_values, rho_x/max(rho_x)/4, label=r'distribution of $X_{t+dt}} }, color='k')
    
    # Plot the Gaussian distribution over ys as (rho_y(y), y)
    y_values = np.linspace(y_dist.mean() - 3*y_dist.std(), y_dist.mean() + 3*y_dist.std(), 100)
    rho_y = y_dist.pdf(y_values)
    plt.plot(rho_y/max(rho_y)/4, y_values, label=r'distribution of $f(X_{t+dt})}} , color='k')
    
    plt.legend(loc='upper left')
    
    plt.grid()
    plt.savefig("ito_lemma.svg")
    plt.show()
    

    Date
    Source Own work
    Author Cosmia Nebula

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    image/svg+xml

    f64a332a5fc80b4d0428ba75ac9d0abbb30603f8

    128,971 byte

    432 pixel

    576 pixel

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current02:18, 18 October 2023Thumbnail for version as of 02:18, 18 October 2023576 × 432 (126 KB)wikimediacommons>Cosmia NebulaUploaded while editing "Itô's lemma" on en.wikipedia.org

    There are no pages that use this file.