-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a proper get_update_sequence function
- Loading branch information
1 parent
198245f
commit db5910c
Showing
13 changed files
with
308 additions
and
111 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod network; | ||
pub mod model; | ||
pub mod utils; | ||
pub mod math; | ||
pub mod updates; |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod posterior; | ||
pub mod prediction; | ||
pub mod prediction_error; | ||
pub mod prediction_error; | ||
pub mod observations; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::model::{Network, Node}; | ||
|
||
|
||
/// Inject new observations into an input node | ||
/// | ||
/// # Arguments | ||
/// * `network` - The main network containing the node. | ||
/// * `node_idx` - The input node index. | ||
/// * `observations` - The new observations. | ||
/// | ||
/// # Returns | ||
/// * `network` - The network after message passing. | ||
pub fn observation_update(network: &mut Network, node_idx: usize, observations: f64) { | ||
|
||
match network.nodes.get_mut(&node_idx) { | ||
Some(Node::Exponential(ref mut node)) => { | ||
node.mean = observations; | ||
} | ||
_ => (), | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::model::Network; | ||
|
||
/// Posterior update from a continuous state node | ||
/// | ||
/// # Arguments | ||
/// * `network` - The main network containing the node. | ||
/// * `node_idx` - The node index. | ||
/// | ||
/// # Returns | ||
/// * `network` - The network after message passing. | ||
pub fn posterior_update_continuous_state_node(network: &mut Network, node_idx: usize) { | ||
let a = 1; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
use crate::network::ExponentialFamiliyStateNode; | ||
use crate::model::{Network, Node}; | ||
use crate::math::sufficient_statistics; | ||
|
||
pub fn posterior_update_exponential(node: &mut ExponentialFamiliyStateNode) { | ||
let suf_stats = sufficient_statistics(&node.mean); | ||
for i in 0..suf_stats.len() { | ||
node.xis[i] = node.xis[i] + (1.0 / (1.0 + node.nus)) * (suf_stats[i] - node.xis[i]); | ||
/// Updating an exponential family state node | ||
/// | ||
/// # Arguments | ||
/// * `network` - The main network containing the node. | ||
/// * `node_idx` - The node index. | ||
/// | ||
/// # Returns | ||
/// * `network` - The network after message passing. | ||
pub fn posterior_update_exponential_state_node(network: &mut Network, node_idx: usize) { | ||
|
||
match network.nodes.get_mut(&node_idx) { | ||
Some(Node::Exponential(ref mut node)) => { | ||
let suf_stats = sufficient_statistics(&node.mean); | ||
for i in 0..suf_stats.len() { | ||
node.xis[i] = node.xis[i] + (1.0 / (1.0 + node.nus)) * (suf_stats[i] - node.xis[i]); | ||
} | ||
} | ||
_ => (), | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::model::Network; | ||
|
||
/// Prediction from a continuous state node | ||
/// | ||
/// # Arguments | ||
/// * `network` - The main network containing the node. | ||
/// * `node_idx` - The node index. | ||
/// | ||
/// # Returns | ||
/// * `network` - The network after message passing. | ||
pub fn prediction_continuous_state_node(network: &mut Network, node_idx: usize) { | ||
let a = 1; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod continuous; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::model::Network; | ||
|
||
/// Prediction error from a continuous state node | ||
/// | ||
/// # Arguments | ||
/// * `network` - The main network containing the node. | ||
/// * `node_idx` - The node index. | ||
/// | ||
/// # Returns | ||
/// * `network` - The network after message passing. | ||
pub fn prediction_error_continuous_state_node(network: &mut Network, node_idx: usize) { | ||
let a = 1; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub mod nodes; | ||
pub mod continuous; |
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.