```python
import numpy as np
import sympy as sm
sm.init_printing()
```


```python
epsilon = 1.0
state_energies = np.array([0, 1, 1, 1])*epsilon
```


```python
def ways(state_energies, T, kB, numpy=True):
    if numpy:
        return np.exp(-state_energies/ (kB*T))
    else:
        return [sm.exp(-e / (kB*T)) for e in state_energies]
```


```python
w = ways(state_energies, T=1, kB=1)
```


```python
def probabilities(state_energies, T, kB, numpy=True):
    w = ways(state_energies, T, kB, numpy)
    if numpy:
        return w / sum(w)
    else:
        total_ways = sum(w)
        return [way/total_ways for way in w]
```


```python
probabilities(state_energies, 1, kB=1)
```




    array([0.47536689, 0.1748777 , 0.1748777 , 0.1748777 ])




```python
epsilon, k_B, T = sm.symbols('epsilon k_B T', positive=True)
i = sm.symbols('i', integer=True, nonnegative=True)
se = [0, epsilon, epsilon, epsilon]
```


```python
probabilities(se, T, k_B, False)
```


```python
def ways_levels(level_energies, level_degeneracies, T, kB, numpy=True):
    if numpy:
        return np.exp(-level_energies/ (kB*T))*level_degeneracies
    else:
        return [g*sm.exp(-e / (kB*T)) for e, g in zip(level_energies, level_degeneracies)]
```


```python
wl = ways_levels(sm.sequence(i*(i+1)*epsilon, (i, 0, 10)), sm.sequence(2*i+1, (i, 0, 10)), T, k_B, False)
```


```python
def probabilities_levels(level_energies, level_degeneracies, T, kB, numpy=True):
    w = ways_levels(state_energies, level_degeneracies, T, kB, numpy)
    if numpy:
        return w / sum(w)
    else:
        total_ways = sum(w)
        return [way/total_ways for way in w]
```


```python
probabilities_levels()
```

0a62f46223bcbc74870fb1c74d45ab1d5bf1cdeb
ipynb
Jupyter Notebook
notebooks/Untitled1.ipynb
ryanpdwyer/pchem
ad097d7fce07669f4ad269e895e2185fa51ac2d2
MIT
notebooks/Untitled1.ipynb
ryanpdwyer/pchem
ad097d7fce07669f4ad269e895e2185fa51ac2d2
MIT
notebooks/Untitled1.ipynb
ryanpdwyer/pchem
ad097d7fce07669f4ad269e895e2185fa51ac2d2
MIT
Qwen/Qwen-72B
1. YES
2. YES