Estrategias Psicológicas para Superar Presiones Adversas
Las estrategias psicológicas pueden marcar la diferencia entre ganar o perder cuando las tensiones aumentan dentro del campo.
- Técnicas de Visualización: Los jugadores practican visualizaciones detalladas donde imaginan ejecuciones exitosas, lo cual puede ayudarles a mantenerse enfocados bajo presión.
-
Rutinas Breves pero Efectivas:
Técnicas como respiraciones profundas o afirmaciones positivas pueden
ayudar a reducir ansiedades durante momentos críticos.
Koryak11/MarkovModel<|file_sep|>/src/markov_model.py
from numpy.random import choice
from collections import defaultdict
class MarkovModel(object):
"""
Class for Markov model.
Takes as input string with separated tokens and number of steps to generate new text.
Methods:
__init__: initializes model
generate_text: generates text using model
get_next_state: returns next state based on current state and model
get_probabilities: returns dictionary with probabilities of next states for given state
"""
def __init__(self):
"""
Initializes model with empty dictionary of transitions.
Also initializes variable to store number of steps to generate text.
"""
self.transitions = defaultdict(lambda : defaultdict(int))
self.steps = None
def generate_text(self):
"""
Generates text using model and number of steps.
Returns:
Generated text as string
"""
if not self.transitions:
raise Exception('Model is empty')
if not self.steps:
raise Exception('Number of steps is not set')
initial_state = list(self.transitions.keys())[0]
current_state = initial_state
result = [current_state]
for i in range(self.steps):
next_state = self.get_next_state(current_state)
result.append(next_state)
current_state = next_state
return ' '.join(result)
def get_next_state(self,state):
"""
Returns next state based on current state and model.
Parameters:
state - current state
Returns:
Next state as string
"""
probabilities = self.get_probabilities(state)
return choice(list(probabilities.keys()), p=list(probabilities.values()))
def get_probabilities(self,state):
"""
Returns dictionary with probabilities of next states for given state.
Parameters:
state - current state
Returns:
Dictionary with probabilities of next states for given state
"""
sum_states = sum(self.transitions[state].values())
if not sum_states:
raise Exception('Sum of states is zero')
probabilities = {state : value/sum_states for state,value in self.transitions[state].items()}
return probabilities
def learn(self,text,n):
"""
Learns transitions from given text.
Parameters:
text - text to learn from
n - size of transition
Example:
If n=2 and text='A AB ABC ABCD ABCDE', then learned transitions are
{'A' : {'B' :1}, 'AB': {'C' :1}, 'ABC': {'D' :1}, 'ABCD': {'E' :1}}
If n=1 and text='A AB ABC ABCD ABCDE', then learned transitions are
{'A' : {'A' :1,'B' :1}, 'B' : {'A' :1,'C' :1}, 'C' : {'B' :1,'D' :1},
'D' : {'C' :1,'E' :1}}
If n=0 and text='A AB ABC ABCD ABCDE', then learned transitions are
{'': {'A' :5}}
If n=2 and text='AA AB AC AD AE', then learned transitions are
{'AA': {'A' :2}, 'AB': {'B':1}, 'AC': {'C':1}, 'AD': {'D':1}, 'AE': {'' :1}}
If n=1 and text='AA AB AC AD AE', then learned transitions are
{'A': {'A' :2,'B' :1,'C' :1,'D' :1,'E' :1}}
If n=0 and text='AA AB AC AD AE', then learned transitions are
{'':{'AA':2,'AB':1,'AC':1,'AD':1,'AE':1}}
If n=-2 and text='AA AB AC AD AE', then learned transitions are
{'AA':{'AA':1,'AB':1}, 'AB':{'AC':1}, 'AC':{'AD':1}, 'AD':{'AE':1}}
If n=-3 and text='AA AB AC AD AE', then learned transitions are
{'':'AA'}
def set_steps(self,number_of_steps):
if number_of_steps <=0:
raise Exception('Number of steps should be positive')
self.steps = number_of_steps
if __name__ == '__main__':
test_text_0 = '''I have been engaged in the manufacturing business for nearly twenty years,
during which time I have had ample opportunity for observation and reflection,
having at different times been connected with many different manufactories.'''
test_text_0_tokens = test_text_0.split()
test_model_0 = MarkovModel()
test_model_0.learn(test_text_0_tokens,n=2)
test_model_0.set_steps(50)
print(test_model_0.generate_text())
<|repo_name|>eduardomoraes/galaxy<|file_sep|>/src/components/Select.vue