Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/nodes/GENERATORS/SIMULATIONS/POPULATE/POPULATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

[//]: # (Custom component imports)

import DocString from '@site/src/components/DocString';
import PythonCode from '@site/src/components/PythonCode';
import AppDisplay from '@site/src/components/AppDisplay';
import SectionBreak from '@site/src/components/SectionBreak';
import AppendixSection from '@site/src/components/AppendixSection';

[//]: # (Docstring)

import DocstringSource from '!!raw-loader!./a1-[autogen]/docstring.txt';
import PythonSource from '!!raw-loader!./a1-[autogen]/python_code.txt';

<DocString>{DocstringSource}</DocString>
<PythonCode GLink='GENERATORS/SIMULATIONS/POPULATE/POPULATE.py'>{PythonSource}</PythonCode>

<SectionBreak />



[//]: # (Examples)

## Examples

import Example1 from './examples/EX1/example.md';
import App1 from '!!raw-loader!./examples/EX1/app.json';



<AppDisplay
nodeLabel='POPULATE'
appImg={''}
outputImg={''}
>
{App1}
</AppDisplay>

<Example1 />

<SectionBreak />



[//]: # (Appendix)

import Notes from './appendix/notes.md';
import Hardware from './appendix/hardware.md';
import Media from './appendix/media.md';

## Appendix

<AppendixSection index={0} folderPath='nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/'><Notes /></AppendixSection>
<AppendixSection index={1} folderPath='nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/'><Hardware /></AppendixSection>
<AppendixSection index={2} folderPath='nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/'><Media /></AppendixSection>


Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
The POPULATE node generates random numbers, depending on the distribution selected and the input data.

Inputs
------
default : OrderedPair|Vector
Input to use as the x-axis for the random samples.

Parameters
----------
distribution : select
the distribution over the random samples
lower_bound : float
the lower bound of the output interval
upper_bound : float
the upper bound of the output interval
normal_mean : float
the mean or "center" of the normal distribution
normal_standard_deviation : float
the spread or "width" of the normal distribution
poisson_events : float
the expected number of events occurring in a fixed time-interval when distribution is poisson

Returns
-------
OrderedPair
x: provided from input data
y: the random samples
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import random
import numpy as np
from flojoy import flojoy, OrderedPair, Vector, display
from typing import Literal, Optional


@flojoy
def POPULATE(
default: OrderedPair | Vector,
distribution: Literal["normal", "uniform", "poisson"] = "normal",
lower_bound: float = 0,
upper_bound: float = 1,
normal_mean: float = 0,
normal_standard_deviation: float = 1,
poisson_events: float = 1,
) -> OrderedPair:


if upper_bound < lower_bound:
upper_bound, lower_bound = lower_bound, upper_bound

seed = random.randint(1, 10000)
my_generator = np.random.default_rng(seed)

match default:
case OrderedPair():
size = len(default.x)
x = default.x
case Vector():
size = len(default.v)
x = default.v

match distribution:
case "uniform":
y = my_generator.uniform(low=lower_bound, high=upper_bound, size=size)
case "normal":
y = my_generator.normal(
loc=normal_mean, scale=normal_standard_deviation, size=size
)
case "poisson":
y = my_generator.poisson(lam=poisson_events, size=size)

return OrderedPair(x=x, y=y)


@display
def OVERLOAD(lower_bound, upper_bound, distribution="uniform") -> None:
return None


@display
def OVERLOAD(normal_mean, normal_standard_deviation, distribution="normal") -> None:
return None


@display
def OVERLOAD(poisson_events, distribution="poisson") -> None:
return None
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This node does not require any peripheral hardware to operate. Please see INSTRUMENTS for nodes that interact with the physical world through connected hardware.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No supporting screenshots, photos, or videos have been added to the media.md file for this node.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No theory or technical notes have been contributed for this node yet.
Loading