npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fis-tsukamoto

v1.0.5

Published

Tsukamoto Fuzzy Inference System written in TypeScript

Readme

Tsukamoto Fuzzy Inference System (FIS)

npm version license npm downloads

A lightweight TypeScript library for implementing the Tsukamoto Fuzzy Inference System.

Features

  • Built-in Membership Functions: Supports DOWN, UP, UPDOWN (triangular), TRAPEZE (trapezoidal), and GAUSS (Gaussian) terms.
  • Automatic Defuzzification: Computes crisp outputs using weighted average defuzzification.
  • Visualization Support: Helper method getChartData() to export membership function curves for easy plotting.
  • Fully Typed: Built with TypeScript with exports for all classes and enums.

Installation

npm install fis-tsukamoto

Quick Start Example

Here is a classic example modeling a Tipping System based on Service Quality and Food Quality.

import { TsukamotoFis, Variable, Term, Rule, TermType } from "fis-tsukamoto";

// 1. Define Input Variables & Membership Functions (Terms)
const service = new Variable({
  name: "Service",
  terms: [
    new Term({ name: "poor", type: TermType.DOWN, x: [2, 6] }),
    new Term({ name: "good", type: TermType.UP, x: [4, 8] }),
  ],
});

const food = new Variable({
  name: "Food",
  terms: [
    new Term({ name: "rancid", type: TermType.DOWN, x: [3, 7] }),
    new Term({ name: "delicious", type: TermType.UP, x: [5, 9] }),
  ],
});

// 2. Define Output Variable
// NOTE: Tsukamoto output terms MUST use either TermType.UP or TermType.DOWN
const tip = new Variable({
  name: "Tip",
  terms: [
    new Term({ name: "cheap", type: TermType.DOWN, x: [5, 15] }),
    new Term({ name: "generous", type: TermType.UP, x: [10, 25] }),
  ],
});

// 3. Define Rules
// Rule inputs map order-wise to the input variables array
const rules = [
  new Rule({ input: ["poor", "rancid"], output: "cheap" }),
  new Rule({ input: ["good", "delicious"], output: "generous" }),
];

// 4. Initialize the Tsukamoto System
const fis = new TsukamotoFis({
  name: "Tip Calculator",
  inputvar: [service, food],
  outputvar: tip,
  rules: rules,
});

// 5. Calculate Crisp Output
// Input values map to [service, food]
const result = fis.calculate([3, 8]);
console.log(`Calculated Tip: ${result}`);

Membership Function Types (TermType)

| Type | Array x Parameters | Description | Valid for Output Term? | | :----------------- | :-------------------- | :--------------------------------------- | :--------------------- | | TermType.DOWN | [start, end] | Monotonically decreasing linear function | Yes | | TermType.UP | [start, end] | Monotonically increasing linear function | Yes | | TermType.UPDOWN | [left, peak, right] | Triangular function | No | | TermType.TRAPEZE | [a, b, c, d] | Trapezoidal function | No | | TermType.GAUSS | [mean, stdev] | Gaussian curve function | No |

⚠️ Important: Tsukamoto inference requires monotonous output membership functions. Therefore, your outputvar terms must use either TermType.UP or TermType.DOWN.

API Reference

Term

Represents a membership function for a variable.

  • calculate(input: number): number: Returns the membership value ($\alpha$) between $0$ and $1$.
  • output(alpha: number): number: Inverts the membership function to solve for crisp value $z$. (Only for UP / DOWN types).

Variable

Groups terms together into a named variable.

  • getTerm(name: string): Term: Retrieves a Term instance by name.
  • getChartData(minX: number, maxX: number, resolution?: number): { term: string, x: number, y: number }[]: Generates dynamic coordinates [{ term, x, y }] useful for plotting graphs.

TsukamotoFis

The core engine.

  • calculate(input: number[]): number: Accepts an array of numeric inputs matching the order of inputvar and returns the final defuzzified output value.

License

MIT