Gaussian

Struct Gaussian 

Source
pub struct Gaussian { /* private fields */ }

Implementations§

Source§

impl Gaussian

Source

pub fn new(mean: f64, variance: f64) -> Self

Examples found in repository?
examples/function_approximation.rs (line 27)
11fn main() {
12    let x1 = 0.0;
13    let x2 = 0.25;
14    let x3 = 0.5;
15    let x4 = 0.75;
16    let x5 = 1.0;
17    let original_function = |x| x * (1.0 - x);
18    let y15 = original_function(x1);
19    let y24 = original_function(x2);
20    let y3 = original_function(x3);
21
22    let mut fis = TSKFIS::new(SNorms::Max, TNorms::Min, TSKDefuzzifiers::Mean);
23
24    let mut x: InputVariable = InputVariable::new("X".to_string(), (0.0, 1.0));
25    x.add_membership(MembershipFunction::new(
26        "x1".to_string(),
27        MFKind::Gaussian(Gaussian::new(x1, 0.09)),
28    ));
29    x.add_membership(MembershipFunction::new(
30        "x2".to_string(),
31        MFKind::Gaussian(Gaussian::new(x2, 0.09)),
32    ));
33    x.add_membership(MembershipFunction::new(
34        "x3".to_string(),
35        MFKind::Gaussian(Gaussian::new(x3, 0.09)),
36    ));
37    x.add_membership(MembershipFunction::new(
38        "x4".to_string(),
39        MFKind::Gaussian(Gaussian::new(x4, 0.09)),
40    ));
41    x.add_membership(MembershipFunction::new(
42        "x5".to_string(),
43        MFKind::Gaussian(Gaussian::new(x5, 0.09)),
44    ));
45    fis.add_input(x);
46
47    let mut y: TSKOutputVariable = TSKOutputVariable::new("Y".to_string());
48    y.add_constant_membership(y15);
49    y.add_constant_membership(y24);
50    y.add_constant_membership(y3);
51
52    fis.add_output(y);
53
54    fis.add_rule(Rule::new_and(vec![0, 0], 1.0));
55    fis.add_rule(Rule::new_and(vec![1, 1], 1.0));
56    fis.add_rule(Rule::new_and(vec![2, 2], 1.0));
57    fis.add_rule(Rule::new_and(vec![3, 1], 1.0));
58    fis.add_rule(Rule::new_and(vec![4, 0], 1.0));
59    
60    let out: Vec<f64> = fis.compute_outputs(vec![0.6]);
61    println!("{:?}", out);
62}

Trait Implementations§

Source§

impl Clone for Gaussian

Source§

fn clone(&self) -> Gaussian

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Gaussian

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl GetDegree for Gaussian

Source§

fn get_degree(&self, x: f64) -> f64

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.