<commit_before># Scientist.NET

This is a .NET Port of the Ruby Scientist library. Read [about it here](http://githubengineering.com/scientist/). And check out a great [success story here](http://githubengineering.com/move-fast/).

Currently, it's a rough sketch of what the library will look like. I tried to stay true to the Ruby implementation with one small difference. Instead of registering a custom experimentation type, you can register a custom observation publisher. We don't have the ability to override the `new` operator like those Rubyists and I liked keeping publishing separate. But I'm not stuck to this idea.

Here's a sample usage.


```csharp
public bool MayPush(IUser user)
{
    return Scientist.Science<bool>("experiment-name", experiment =>
    {
        experiment.Use(() => IsCollaborator(user));
        experiment.Try(() => HasAccess(user));
    });
}
```

You can also specify a custom comparator.

```csharp
public IUser GetCurrentUser(string hash)
{
    return Scientist.Science<IUser>("experiment-name", experiment =>
    {
        experiment.Compare((x, y) => x.Name == y.Name);

        experiment.Use(() => LookupUser(hash));
        experiment.Try(() => RetrieveUser(hash));
    });
}
```

You can also limit the experiments from running.

```csharp
public decimal GetUserStatistic(IUser user)
{
    return Scientist.Science<decimal>("NewStatisticCalculation", experiment =>
    {
        experiment.RunIf(() => user.IsTestSubject);

        experiment.Use(() => CalculateStatistic(user));
        experiment.Try(() => NewCalculateStatistic(user));
    });
}
```

By default observations are stored in an in-memory publisher. For production use, you'll
probably want to implement an `IResultPublisher`.

To give it a twirl, use NuGet to install it.

`Install-Package Scientist -Pre`<commit_msg>Added documentation.<commit_after># Scientist.NET

This is a .NET Port of the Ruby Scientist library. Read [about it here](http://githubengineering.com/scientist/). And check out a great [success story here](http://githubengineering.com/move-fast/).

Currently, it's a rough sketch of what the library will look like. I tried to stay true to the Ruby implementation with one small difference. Instead of registering a custom experimentation type, you can register a custom observation publisher. We don't have the ability to override the `new` operator like those Rubyists and I liked keeping publishing separate. But I'm not stuck to this idea.

Here's a sample usage.


```csharp
public bool MayPush(IUser user)
{
    return Scientist.Science<bool>("experiment-name", experiment =>
    {
        experiment.Use(() => IsCollaborator(user));
        experiment.Try(() => HasAccess(user));
    });
}
```

You can also specify a custom comparator.

```csharp
public IUser GetCurrentUser(string hash)
{
    return Scientist.Science<IUser>("experiment-name", experiment =>
    {
        experiment.Compare((x, y) => x.Name == y.Name);

        experiment.Use(() => LookupUser(hash));
        experiment.Try(() => RetrieveUser(hash));
    });
}
```

You can also limit the experiments from running.

```csharp
public decimal GetUserStatistic(IUser user)
{
    return Scientist.Science<decimal>("NewStatisticCalculation", experiment =>
    {
        experiment.RunIf(() => user.IsTestSubject);

        experiment.Use(() => CalculateStatistic(user));
        experiment.Try(() => NewCalculateStatistic(user));
    });
}
```

To ensure that experimental results always match use `ThrownOnMismatches`.

```csharp
Scientist.Science<int>("ExperimentN", experiment => 
{
    experiment.ThrowOnMismatches = true;
    // ...
})
```

By default observations are stored in an in-memory publisher. For production use, you'll
probably want to implement an `IResultPublisher`.

To give it a twirl, use NuGet to install it.

`Install-Package Scientist -Pre`
{'fraction_non_alphanumeric': 0.11737331954498449, 'fraction_numerical': 0.0, 'mean_word_length': 3.9666238767650834, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4679405', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1053, 'n_words': 378}