<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<?xml-stylesheet href="./_c74_ref.xsl" type="text/xsl"?>

<!--This is an automatically generated file. DO NOT EDIT THIS FILE DIRECTLY. Rather, use the _ref.xml files found in the 'edits' folder.-->
<c74object name="prob" module="max" category="Data">
	<digest>
		Create a weighted transition table
	</digest>
	<description>
		Creates a table of weighted numeric transitions. A <m>bang</m> message causes the weighting, and a potential transition, to be calculated.
	</description>
	<!--METADATA-->
	<metadatalist>
		<metadata name="author">
			Cycling '74
		</metadata>
		<metadata name="tag">
			Max
		</metadata>
		<metadata name="tag">
			math
		</metadata>
		<metadata name="reference">
			TEXT_HERE
		</metadata>
		<metadata name="license">
			TEXT_HERE
		</metadata>
		<metadata name="tag">
			Data
		</metadata>
	</metadatalist>
	<!--INLETS-->
	<inletlist>
		<inlet id="0" type="INLET_TYPE">
			<digest>
				bang Chooses State, list Assigns Transition
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
		<inlet id="1" type="INLET_TYPE">
			<digest>
				bang Chooses State, list Assigns Transition
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
	</inletlist>
	<!--OUTLETS-->
	<outletlist>
		<outlet id="0" type="OUTLET_TYPE">
			<digest>
				State Chosen (int)
			</digest>
			<description>
				TEXT_HERE
			</description>
		</outlet>
		<outlet id="1" type="OUTLET_TYPE">
			<digest>
				bang When In Stuck State
			</digest>
			<description>
				TEXT_HERE
			</description>
		</outlet>
	</outletlist>
	<!--ARGUMENTS-->
	<objarglist>
		<objarg id="0" name="OBJARG_NAME" type="OBJARG_TYPE" optional="0">
			<digest>
				TEXT_HERE
			</digest>
			<description>
				TEXT_HERE
			</description>
		</objarg>
	</objarglist>
	<!--MESSAGES-->
	<methodlist>
		<method name="bang">
			<arglist />
			<digest>
				Output a weighted random value
			</digest>
			<description>
				Makes a weighted random choice of a number to be sent out, based on the immediately previous output and on the specified likelihoods of subsequent numbers. No output will be produced if no input has been received or if the contents of the <o>prob</o> object have been cleared using the <m>clear</m> message.
			</description>
		</method>
		<method name="int">
			<arglist>
				<arg name="input" optional="0" type="int" />
			</arglist>
			<digest>
				Set the current value
			</digest>
			<description>
				Sets (but does not send out) out the current number value. The subsequent output, in response to a <m>bang</m> message, will be determined by the stored matrix of probable transitions from that number.
			</description>
		</method>
		<method name="list">
			<arglist>
				<arg name="matrix" optional="0" type="list" />
			</arglist>
			<digest>
				Set probability matrix entry
			</digest>
			<description>
				The numbers make an entry in a probability matrix of transitions from one number to another (known as a first-order Markov chain). The list should consist of three numbers: a current value, a next value, and a probability that current will be followed by next. The first two numbers in the list identify a possible succession of output values: a possibility that the first number will be followed by the second. The third number sets the relative likelihood that the sequence of numbers will occur. Once the first number has been sent out, the next output is determined by the relative likelihood(s) assigned to each possible subsequent number.
			</description>
		</method>
		<method name="clear">
			<arglist />
			<digest>
				Clear all values
			</digest>
			<description>
				Erases the contents of the <o>prob</o> object.
			</description>
		</method>
		<method name="embed">
			<arglist>
				<arg name="flag" optional="0" type="int" />
			</arglist>
			<digest>
				Save data with patcher
			</digest>
			<description>
				The word <m>embed</m>, followed by a non-zero number, causes the contents of <o>prob</o> to be saved as part of the patch that contains it. The message <m>embed 0</m> causes <o>prob</o> to forget its contents when the patch is closed.
			</description>
		</method>
		<method name="dump">
			<arglist />
			<digest>
				Output transitions to the Max Console
			</digest>
			<description>
				Prints out a complete list of the stored transition probabilities (Markov chain) in the Max Console.
			</description>
		</method>
		<method name="reset">
			<arglist>
				<arg name="value" optional="0" type="int" />
			</arglist>
			<digest>
				Store reset number
			</digest>
			<description>
				The word <m>reset</m>, followed by a number, tells <o>prob</o> what number to revert to in the event that it gets &quot;stuck&quot; on a number that has no possible next number.
			</description>
		</method>
	</methodlist>
	<!--ATTRIBUTES-->
	<!--EXAMPLE-->
	<examplelist>
		<example img="prob.png" caption="Likelihood of a certain output depends on the previous output" />
	</examplelist>
	<!--SEEALSO-->
	<seealsolist>
		<seealso name="anal" />
		<seealso name="histo" />
		<seealso name="mean" />
		<seealso name="datachapter05" module="max" type="tutorial" />
	</seealsolist>
	<discussion>
		<o>prob</o> accepts lists of three numbers in its inlet. The third number represents the weight of the probability of going from states represented by the first two numbers. For example, <m>1 2 4</m> would mean that there is a weight of 4 in going from state 1 to state 2. When <o>prob</o> receives a <m>bang</m>, it makes a random jump from its current state to another state based on its current weighting of transitions. If a transition can be made, the new state is sent out the left outlet. If not, a <m>bang</m> is sent out the right outlet. For any particular state, the weights of all possible transition states are summed. Thus if a state could jump to three states that had weights of 3 4 and 1, the first one (3) would occur 37.5% of the time, the second 50% of the time, and the third 12.5%. Note that any state can make a transition to itself with a list of the form (state state weight).
	</discussion>
	<misc name="Output">
		<entry name="int">
			<description>
				Out left outlet: When <m>bang</m> is received in the inlet, <o>prob</o> sends out a number, which it chooses based on its knowledge of the last number chosen and the relative likelihood assigned to each possible subsequent number.
			</description>
		</entry>
		<entry name="bang">
			<description>
				Out right outlet: If the current number (the last number chosen) has no possible transitions listed in the transition probability matrix, <m>bang</m> is sent out (and nothing is sent out the left outlet) in response to a <m>bang</m> in the inlet.
			</description>
		</entry>
	</misc>
</c74object>
