This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define N_SAMPLES 64 | |
void setup() | |
{ | |
Serial.begin(9600); | |
while (!Serial) delay(10); | |
} | |
void loop() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib notebook\n", | |
"import collections\n", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This script is an example of learning parameters of a Bayesian network | |
with hidden variables. The following Bayesian net is analyzed: | |
(hidden) (observable) | |
K -----------> A | |
Where K (knowledge) is not observable and A (answers), which depends on K, is. |
I hereby claim:
- I am rbaron on github.
- I am rbaron (https://keybase.io/rbaron) on keybase.
- I have a public key whose fingerprint is B22D 7692 7828 E780 B3C4 8A20 28F6 64EB A5ED B223
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def take(n, iterable): | |
return list(itertools.islice(iterable, n)) | |
def enum_integers(start): | |
return itertools.count(start) | |
def is_not_divisible_by(n, which): | |
return n%which != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Indiv[V <: Indiv[V]] { | |
val fitness: Double | |
def reproduce(other: V): V | |
} | |
class RealIndiv[V](override val fitness: Double) extends Indiv[V] { | |
override def reproduce(other: V) = new RealIndiv(fitness + other.fitness) | |
// ^ Cannot resolve symbol fitness (on `other.fitness`) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Individual[T] { | |
def mate(other: Individual[T]): Individual[T] | |
} | |
class Person[T] extends Individual[T] { | |
// This "overrides nothing": | |
override def mate(other: Person[T]): Person[T] = new Person[T]() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package objsets | |
import common._ | |
import TweetReader._ | |
/** | |
* A class to represent tweets. | |
*/ | |
class Tweet(val user: String, val text: String, val retweets: Int) { | |
override def toString: String = |