<jupyter_start><jupyter_text>TODO :  - how to make UV attributes like std, skew, accessible ? using q.value.skew ?  - multiplication precedence : `x = mcerp.Normal(1, 2)*s` doesn't work because mcerp can't cast quantity object to UV  mcerpSee : - github : https://github.com/tisimst/mcerp - online doc : https://pythonhosted.org/mcerp/  Introduction on mcerp UV : uncertain Variable liste of distributions : https://pythonhosted.org/mcerp/distribution_constructors.html<jupyter_code>import mcerp
mcerp.npts = 12_000
x = mcerp.Normal(1, 3, tag="toto")
y = mcerp.Normal(2, 5)
print(x)
print(y)
print(x.mean)
print(x.var)
print(x.kurt)
print(x.skew)
print(mcerp.npts)
print(x.tag)
x.describe()
y.describe()
x.plot()
y.plot()
print(x.tag)
z = x + y
z.describe()
z.plot()
print(2*z)
print(z*2)
print(2**z)
print(z**2)
print(2/z)
print(z/2)
print(2//z)
print(z//2)<jupyter_output>uv(6.000201568184154, 136.39051926470387, 0.01874343712546578, 2.938235907979163)
uv(6.000201568184154, 136.39051926470387, 0.01874343712546578, 2.938235907979163)
uv(11207.995718934571, 75102293882.39592, 54.843733156509025, 3615.4441281265754)
uv(43.09823453088587, 3525.8688226662603, 2.5586418820702423, 12.170265807762418)
uv(-0.06928598633554382, 249.7684782903027, -15.776155195034734, 1161.1394102054376)
uv(1.5000503920460384, 8.524407454043992, 0.01874343712546578, 2.938235907979163)<jupyter_text>Support with physipy<jupyter_code>import physipy 
from physipy import m, cd, s, Quantity, Dimension<jupyter_output><empty_output><jupyter_text>Construction<jupyter_code>x = Quantity(mcerp.Normal(1, 2), Dimension("L"))
x
# using multiplication
# x = mcerp.Normal(1, 2)*s : NotUpcast: <class 'physipy.quantity.quantity.Quantity'> cannot be converted to a number with uncertainty
x = s *mcerp.Normal(1, 2)
x<jupyter_output><empty_output><jupyter_text>Basic Operation<jupyter_code># with scalar
s = 2*m
print(x+s)
print(x-s)
print(x*s)
print(x/s)
# print(x**s) : NotUpcast: <class 'physipy.quantity.quantity.Quantity'> cannot be converted to a number with uncertainty

print(s+x)
print(s-x)
print(s*x)
print(s/x)
# print(x**s) : NotUpcast: <class 'physipy.quantity.quantity.Quantity'> cannot be converted to a number with uncertainty

# with other uv
x = Quantity(mcerp.Normal(1, 2), Dimension("L"))
y = Quantity(mcerp.Normal(1, 2), Dimension("L"))

print(x+y)
print(x-y)
print(x*y)
print(x/y)
# print(x**y) : NotUpcast: <class 'physipy.quantity.quantity.Quantity'> cannot be converted to a number with uncertainty

print(y+x)
print(y-x)
print(y*x)
print(y/x)
# print(y**x) : NotUpcast: <class 'physipy.quantity.quantity.Quantity'> cannot be converted to a number with uncertainty<jupyter_output>uv(1.9998194729311387, 8.076306197292078, 0.0005523833482633396, 3.0800987793853376) m
uv(3.264955504208918e-05, 7.92528720301836, -0.005229009357082663, 3.0180913861698) m
uv(1.0375742293805756, 24.626620937405843, 0.8875461893383568, 8.610304004536113) m**2
uv(1.714470707297022, 15254.726786153124, 35.99321215602319, 3042.5319198285174)
uv(1.9998194729311387, 8.076306197292078, 0.0005523833482633396, 3.0800987793853376) m
uv(-3.264955504208918e-05, 7.92528720301836, 0.005229009357082663, 3.0180913861698) m
uv(1.0375742293805756, 24.626620937405843, 0.8875461893383568, 8.610304004536113) m**2
uv(-10.298305897771893, 1327198.8651144467, -108.74445949787064, 11883.716327161823)<jupyter_text>FunctionnalitiesUse `q.value.` to acces mcerp attributes<jupyter_code>x.value.describe()
x.value.skew
print(x.value.stats)<jupyter_output>MCERP Uncertain Value:
 > Mean...................  0.9999266988104079
 > Variance...............  3.9991531304872696
 > Skewness Coefficient... -0.0014373721916087917
 > Kurtosis Coefficient...  2.9944020939404177

[0.9999266988104079, 3.9991531304872696, -0.0014373721916087917, 2.9944020939404177]<jupyter_text>Examples<jupyter_code>from mcerp import N, U, Gamma, Beta, Exp, H
x1 = m * N(24, 1)
x2 = m * N(37, 4)
x3 = s * Exp(2)
# x1.mean
print("x1.mean")
print(x1.mean) # falls back on UV value, hence drops the unit
# x1.mean() : fails because relies on numpy.mean

# x1.var
print("x1.var")
print(x1.var) # falls back on UV value, hence drops the nit

# x1.skew
print("x1.skew")
print(x1.skew) # falls back on UV value, hence drops the nit

# x1.kurt
print("x1.kurt")
print(x1.kurt)

# x1.stats
print("x1.stats")
print(x1.stats)

# Z = (x1*x2**2)/(15*(1.5 + x3))
Z = (x1*x2**2)/(15*(1.5*s + x3))
print(Z)

# Z.describe()
Z.describe()<jupyter_output>x1.mean
<bound method Quantity.mean of <Quantity : uv(23.999975288883657, 0.9998984642028829, -0.0010968371368921842, 2.996748827861545) m, symbol=UndefinedSymbol*m>>
x1.var
0.9998984642028829
x1.skew
-0.0010968371368921842
x1.kurt
2.996748827861545
x1.stats
[23.999975288883657, 0.9998984642028829, -0.0010968371368921842, 2.996748827861545]
uv(1161.2895629578375, 116037.17275628561, 0.333666658312887, 2.9871627071422533) m**3/s
MCERP Uncertain Value:
 > Mean...................  1161.2895629578375
 > Variance...............  116037.17275628561
 > Skewness Coefficient...  0.333666658312887
 > Kurtosis Coefficient...  2.9871627071422533<jupyter_text>Distributions<jupyter_code>mu = 1
sigma = 0.1
x = s * mcerp.Normal(mu, sigma)
# y = mcerp.Normal(mu*s, sigma*s) # fails because "assert sigma > 0, "
import scipy.stats as ss
x = s * mcerp.uv(ss.norm(loc=10, scale=1))
x
distrib = ss.norm(loc=10*s, scale=1*s)
distrib.mean() # unit is stripped, not mcerp's fault
y = mcerp.uv(distrib)
y<jupyter_output><empty_output><jupyter_text>Plotting<jupyter_code># x1.plot() : fails because uses Quantity.plot, which doesn't handle mcerp
x1.value.plot()
# fails because of matploltib version on normed 
x1.value.plot(hist=True)
rvs1 = m*N(5, 10)
rvs2 = m*N(5, 10) + m*N(0, 0.2)
rvs3 = m*N(8, 10) + m*N(0, 0.2)
from scipy.stats import ttest_rel
tstat, pval = ttest_rel(rvs1._mcpts, rvs2._mcpts)
pval
rvs1<rvs2
tstat, pval = ttest_rel(rvs1._mcpts, rvs3._mcpts)
pval
float(tstat)
rvs1<rvs3
x = N(0, 1)
y = N(0, 10)
x<y
x>y
x==y
x1==x1
n1 = s*N(0, 1)
n2 = s*N(0, 1)
n1==n2
print(Z*Z)
print(Z**2)
Z*Z == Z**2
h = s*H(50, 5, 10)
h==4
h<=3*s
n = s*N(0, 1)
n==0*s
n==0.5*s
n==1.2345*s<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15855241804608894, 'fraction_numerical': 0.2539759818240831, 'mean_word_length': 5.46694648478489, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 46, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '273595', 'license': 'MIT', 'n_tokens_mistral': 3690, 'n_tokens_neox': 2761, 'n_words': 517, 'path': 'docs/Support of mcerp.ipynb', 'repo_name': 'mocquin/physipy', 'size': '6162'}