# Cred Analysis Notebooks

**URL:** <https://discourse.sourcecred.io/t/cred-analysis-notebooks/267>\
**Category:** Initiatives\
**Tags:** 🌱up-for-adoption\
**Created:** [October 5, 2019, 5:30pm UTC](https://discourse.sourcecred.io/t/cred-analysis-notebooks/267 "2019-10-05T17:30:13Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![burrrata](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sourcecred.io/burrrata/32/135_2.png) [@burrrata](https://discourse.sourcecred.io/u/burrrata)\
**Post date:** [December 30, 2019, 1:02am UTC](https://discourse.sourcecred.io/t/cred-analysis-notebooks/267/5 "2019-12-30T01:02:26Z")

</div>

> Reading through the code and notebooks attempting to understand what’s going on. Since I always take notes, might as well keep track of them here in case that’s useful for anyone.

## [Payout Notebooks](https://discourse.sourcecred.io/t/sourcecred-contributor-payouts/298)

Starting with these because they’re the most updated notebooks that the SourceCred community seems to have. Looks like the way the notebooks work is that someone runs the SoruceCred protocol over SourceCred’s [GitHub](https://github.com/sourcecred/) (is it just the `sourcecred` repo, or all the repos?) and [Discourse](https://discourse.sourcecred.io/). Then that someone (currently @decentralion) updates the [Cred](https://github.com/sourcecred/cred) repo with that week’s weights and scores. Then that data is put into an Observable notebook (like [this one](https://observablehq.com/@decentralion/credsperiment-week-14)) by linking to the `scores_file` and the `distribution_history_file`.

So the notebooks in the [SourceCred Contributor Payouts](https://discourse.sourcecred.io/t/sourcecred-contributor-payouts/298) thread _only_ compute the Grain payouts based on the Cred scores. If we wanted to create notebooks to calculate how Cred might fluctuate with the introduction of various mechanisms we would need an entirely different system because we would be modeling the Cred itself, not the Grain that is a result of the Cred.

  

## [Cred Repo](https://github.com/sourcecred/cred)

In the Cred repo [weights file](https://github.com/sourcecred/cred/blob/master/weights.json) it looks like there’s some things that have been manually bumped 4X:

```auto
   "nodeManualWeights": {
      "N\u0000sourcecred\u0000discourse\u0000topic\u0000https://discourse.sourcecred.io\u0000248\u0000": 8,
      "N\u0000sourcecred\u0000discourse\u0000topic\u0000https://discourse.sourcecred.io\u0000269\u0000": 4,
      "N\u0000sourcecred\u0000discourse\u0000topic\u0000https://discourse.sourcecred.io\u0000270\u0000": 4,
      "N\u0000sourcecred\u0000discourse\u0000topic\u0000https://discourse.sourcecred.io\u0000291\u0000": 4,
      "N\u0000sourcecred\u0000discourse\u0000topic\u0000https://discourse.sourcecred.io\u0000327\u0000": 4
    },

```

According to [this Issue](https://github.com/sourcecred/cred/pull/4/) and [this commit](https://github.com/sourcecred/cred/commit/ac860595927007b62d4cd276566bcaa376f3b264) these correlate to:

- Produce the SourceCred Podcast: Shipped the podcast!
- Discourse Reference Detection: Recently completed.
- Champions & Heroes: An exciting contribution. 🙂
- Initiatives Plugin: Nice progress so far.
- Community call notes

Would be great if we had code comments here to explain that, but JSON does not allow for comments right?

  

## How is Cred computed?

A little confused because Cred is computed in the main [SourceCred repo](https://github.com/sourcecred/sourcecred) in the [weightEvaluator](https://github.com/sourcecred/sourcecred/blob/master/src/analysis/weightEvaluator.js) file (so that you can download it and run it on arbitrary repos and forums), and it’s also computed in plugins like [Initiatives](https://github.com/sourcecred/sourcecred/blob/master/src/plugins/initiatives/declaration.js) (so that plugins define their own logic), and Cred is computed in the [Cred repo](https://github.com/sourcecred/cred) (not sure why there’s weights here and in the main repo). Why is Cred computed in so many places, or am I just misinterpreting the codebase?

  

## How does Cred flow?

Reading through [pagerankGraph.js](https://github.com/sourcecred/sourcecred/blob/master/src/core/pagerankGraph.js):

```auto
 * Every edge in the Graph is assigned an `EdgeWeight`, which includes a
 * `forwards` (weight from the `src` to the `dst`) and a `backwards`
 * (weight from the `dst` back to the `src`). Both `forwards` and
 * `backwards` must be nonnegative numbers. The weights influence how
 * score flows from node to node. For example, if the node `root` is
 * connected to `a` with a weight of `1` and to `b` with a weight of `2`,
 * then `b` will recieve twice as much score from `root` as `a` does.

```

Discussing how exactly this works in the [Questions About Initiatives - #8 by burrrata](https://discourse.sourcecred.io/t/questions-about-initiatives/443/8) thread. Will update this thread with answers once I understand how exactly the connections between nodes works.

Also from [pagerankGraph.js](https://github.com/sourcecred/sourcecred/blob/master/src/core/pagerankGraph.js) it looks like SourceCred [creates a graph](https://github.com/sourcecred/sourcecred/blob/master/src/core/graph.js), then runs a (modified?) [PageRank algorithm to score the graph](https://github.com/sourcecred/sourcecred/blob/master/src/core/pagerankGraph.js), then all the SourceCred specific processing happens afterwards to boost or modify those scores?

```auto
 * At present, PagerankGraph does not support any modification to the
 * underlying Graph; doing so will invalidate PagerankGraph and cause
 * its methods to throw errors.
 */

```

---

_[View the full topic](https://discourse.sourcecred.io/t/cred-analysis-notebooks/267)._
