Adam Coogan
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Gaussian process source [link to somewhere](https://google.com) For now I will assume the instrumental response function just adds Gaussian noise with standard deviation $\sigma_n$. We model the source as a zero-mean Gaussian process in the source plane by attaching a flux $\mu$ to each pixel in the image. With the notation * $\pmb{\mu}$: set of all true fluxes; * $\pmb{\beta}_\mathrm{src}$: set of associated source-plane points; <!-- * $k_\theta(\cdot, \cdot)$: covariance function; --> * $[K_{\theta}(\mathbf{z}^l)]_{ij}$: matrix of covariances between all points, <!-- \equiv k_\theta(\pmb{\beta}_{\mathrm{src},i}, \pmb{\beta}_{\mathrm{src},j})$ --> this means we assume $$ \pmb{\mu} \sim P_N(\pmb{\mu} | \mathbf{0}, K_\theta(\mathbf{z}^l)),\\ \mathbf{x} \sim P_N(\mathbf{x} | \pmb{\mu}, \sigma_n). $$ The covariance matrix depends only on the lensing parameters (and some hyperparameters), since they determine the source-plane points to which each pixel maps. Since we are ultimately not concerned with the true fluxes, we marginalize over them to get the full PDF for our model: $$ p_\theta(\mathbf{x} | \mathbf{z}) = \int d\pmb{\mu} \ P_N(\mathbf{x} | \pmb{\mu}, \sigma_n) \ P_N(\pmb{\mu} | \pmb{0}, K_\theta(z^l)) = P_N(\mathbf{x} | \mathbf{0}, \Sigma_\theta(\mathbf{z}^l))\\ \implies \log p_\theta(\mathbf{x} | \mathbf{z}) = -\frac{1}{2} \mathbf{x}^T \Sigma^{-1} \mathbf{x} - \frac{1}{2} \log |\Sigma| - \frac{N}{2} \log 2\pi, $$ where $\Sigma \equiv K_\theta(\mathbf{z}^l) + \sigma_n^2 I$. Note that we have not introduced any source parameters $\mathbf{z}^s$ so far since we have marginalized them out. For images larger than $\sim 70 \times 70$ pixels, it is impossible to directly maximize this likelihood with respect to the lensing parameters and hyperparameters. Firstly, the covariance matrix is too large to store in memory. While that can be handled using a library like [KeOps](https://www.kernel-operations.io/keops/) to compute the matrix lazily, the log determinant is still intractible. Ultimately we will circumvent this issue by only *sampling* $\mathbf{x} \sim p_\theta(\mathbf{x} | \mathbf{z})$ for fixed lensing and hyperparameters. ## Reparametrizing the likelihood While the first term in the log likelihood can be computed using conjugate gradient, the calculation is quite slow. We can ameliorate this by rewriting the likelihood so the first term can be computed using gradient descent, allowing simultaneous optimization of the lensing parameters. This requires introducing a set of source parameters $\mathbf{z}^s$. The trick is the following identity: $$ \mathbf{x}^T \Sigma^{-1} \mathbf{x} = \min_{\pmb{\mu}} \left\{ \frac{|\mathbf{x} - \pmb{\mu}|^2}{\sigma_n^2} + \hat{\pmb{\mu}}^T K^{-1} \pmb{\mu} \right\}. $$ The expression is minimized by the MAP estimate of the true fluxes, $\hat{\pmb{\mu}} \equiv K \Sigma^{-1} \mathbf{x}$, which must still be computed using conjugate gradient. However, we can reparametrize this using $\mathbf{z}^s \equiv K^{-1} \pmb{\mu}$: $$ \mathbf{x}^T \Sigma^{-1} \mathbf{x} = \min_{\mathbf{z}^s} \left\{ \frac{|\mathbf{x} - K \mathbf{z}^s|^2}{\sigma_n^2} + {\mathbf{z}^s}^T K \mathbf{z}^s \right\}. $$ Now we can optimize with respect to $\mathbf{z}^s$ using gradient descent. At the cost of adding a set of source parameters, we have gained the ability to optimize $p_\theta(\mathbf{x} | \mathbf{z})$ using only gradient descent, and can compute a MAP estimate of the source parameters $\pmb{\mu} = K \mathbf{z}^s$. ## Covariance function from pixel overlaps The covariance between the surface brightness of two pixels depends on how much they overlap in the source plane: $$ K_{ij} \propto \frac{A_{ij}}{A_i A_j}, $$ where $A_{i}$ is the area of pixel $i$ and $A_{ij}$ is overlap area between pixels $i$ and $j$ (traced back to the source plane). This can be written in terms of a _window function_ $g_i(\cdot)$: $$ K_{ij} = \alpha^2 \int d^2\pmb{\beta} \ g_i(\pmb{\beta}) g_j(\pmb{\beta}). $$ ($\alpha$ is a hyperparameter in $\theta$.) The window functions should satisfy $g_i(\pmb{\beta}) \approx A_i^{-1} \ I[\pmb{\beta} \in R_i]$, where $R_i$ is the region which pixel $i$ maps to in the source plane and $I[\cdot]$ is the indicator function (1 if the argument is true, 0 if not). To make this analytically tractable we use Gaussians to approximate the window function, with the following normalization requirement: $$ g_i(\pmb{\beta}) = P_N(\pmb{\beta} | \pmb{\beta}_{\mathrm{src},i}, \Sigma_i),\\ \int d^2\pmb{\beta} \ [g_i(\pmb{\beta})]^2 = A_i^{-1}. $$ The resulting kernel is $$ K_{ij} = \alpha^2 P_N(\pmb{\beta}_{\mathrm{src},i} | \pmb{\beta}_{\mathrm{src},j}, \Sigma_i + \Sigma_j). $$ All that remains is to compute the window function covariance. This depends on $\mathbf{z}^l$ and can be computed using the coordinates of the pixels in the source plane. Let $\mathbf{a}$ be the difference between the source-plane positions to which the image plane pixels above and below pixel $i$ map; let $\mathbf{b}$ be the same for the pixels to the right and left of pixel $i$ in the image plane. Assuming the magnification varies smoothly over these pixels, we have $$ \Sigma_i = \frac{1}{16 \pi} (\mathbf{a} + \mathbf{b}). $$ Lastly, this covariance function can be generalized to include a term for the intrinsic covariance of the source, characterized by the standard Gaussian kernel function $k(\beta, \beta') \equiv P_N(\beta | beta', \sigma)$: $$ K_{ij} = \alpha^2 \int d^2\pmb{\beta} \ g_i(\pmb{\beta}) \ k_\sigma(\pmb{\beta}_{\mathrm{src},i}, \pmb{\beta}_{\mathrm{src},j}) \ g_j(\pmb{\beta})\\ = \alpha^2 P_N(\pmb{\beta}_{\mathrm{src},i} | \pmb{\beta}_{\mathrm{src},j}, \Sigma_i + \Sigma_j + \sigma^2 I). $$ This adds a length scale $\sigma$ to the set of hyperparameters $\theta$. In the limit where the windowing functions are taken to be $\delta$ functions ($\Sigma_i, \Sigma_j \to 0$), this reduces to $\alpha^2 \ k_\sigma(\pmb{\beta}_{\mathrm{src},i}, \pmb{\beta}_{\mathrm{src},j})$, the standard squared-exponential Gaussian process kernel.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully