mirror of
http://CODE.RHODECODE.COM/u/O/O/O
synced 2024-11-25 08:48:39 -05:00
16 lines
4.3 KiB
Python
16 lines
4.3 KiB
Python
import plotly.graph_objects as ⵙᔓᔕ𖧷ᑐᑕᗱᗴᒍᒐ8Oⵔ옷ߦᗩᴥᕤᕦⵙⵔⵙⵔⵙᕤᕦᴥᗩߦ옷ⵔO8ᒍᒐᗱᗴᑐᑕ𖧷ᔓᔕⵙ
|
||
import numpy as ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ
|
||
def ⵙᗱᗴ𖧷ᑎߦᙏOᑐᑕⵙⵔⵙⵔⵙᑐᑕOᙏߦᑎ𖧷ᗱᗴⵙ(x):
|
||
return (1-((-((-1)**ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor(x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)*(ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.exp(-1/((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)-ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2))))
|
||
/(ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.exp(-1/((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)-ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2))))+ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.exp(-1/(1-(x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)+ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2))))))) +
|
||
((-1)**ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)/1)*(ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.exp(-1/(1-(x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)+ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2))))/(ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.exp(-1/((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)-
|
||
ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2))))+ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.exp(-1/(1-(x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2)+ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.floor((x/ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi*2))))))))/2 + .5))
|
||
ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ=ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.linspace(0,4*ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.pi,1000)
|
||
ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔᗩߦᗩ𐊌ⵙⵔⵙⵔⵙ𐊌ᗩߦᗩⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ=ⵙᗱᗴ𖧷ᑎߦᙏOᑐᑕⵙⵔⵙⵔⵙᑐᑕOᙏߦᑎ𖧷ᗱᗴⵙ(ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ)
|
||
ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔᗩ𖧷ᗱᗴ옷𖧷ⵙⵔⵙⵔⵙ𖧷옷ᗱᗴ𖧷ᗩⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ=ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.cumsum(ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔᗩߦᗩ𐊌ⵙⵔⵙⵔⵙ𐊌ᗩߦᗩⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ)*(ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ[1]-ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ[0])
|
||
ⵙᔓᔕᗱᗴ𖧷ᗩИNꖴᗝᴥOᑐᑕⵔꕤⵙⵔⵙⵔⵙꕤⵔᑐᑕOᴥᗝꖴИNᗩ𖧷ᗱᗴᔓᔕⵙ=ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.cumsum(ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.cos(ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔᗩ𖧷ᗱᗴ옷𖧷ⵙⵔⵙⵔⵙ𖧷옷ᗱᗴ𖧷ᗩⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ))*(ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ[1]-ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ[0])
|
||
ⵙᔓᔕᗱᗴ𖧷ᗩИNꖴᗝᴥOᑐᑕⵔ人ⵙⵔⵙⵔⵙ人ⵔᑐᑕOᴥᗝꖴИNᗩ𖧷ᗱᗴᔓᔕⵙ=ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.cumsum(ⵙ人ߦᙏᑎИNⵙ〇ⵙ〇ⵙИNᑎᙏߦ人ⵙ.sin(ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔᗩ𖧷ᗱᗴ옷𖧷ⵙⵔⵙⵔⵙ𖧷옷ᗱᗴ𖧷ᗩⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ))*(ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ[1]-ⵙᔓᔕᗱᗴᑎᙁᗩᗯⵔꕤⵙⵔⵙⵔⵙꕤⵔᗯᗩᙁᑎᗱᗴᔓᔕⵙ[0])
|
||
ⵙᗱᗴᴥᑎᕤᕦꖴꗳⵙⵔⵙⵔⵙꗳꖴᕤᕦᑎᴥᗱᗴⵙ=ⵙᔓᔕ𖧷ᑐᑕᗱᗴᒍᒐ8Oⵔ옷ߦᗩᴥᕤᕦⵙⵔⵙⵔⵙᕤᕦᴥᗩߦ옷ⵔO8ᒍᒐᗱᗴᑐᑕ𖧷ᔓᔕⵙ.Figure()
|
||
ⵙᗱᗴᴥᑎᕤᕦꖴꗳⵙⵔⵙⵔⵙꗳꖴᕤᕦᑎᴥᗱᗴⵙ.add_trace(ⵙᔓᔕ𖧷ᑐᑕᗱᗴᒍᒐ8Oⵔ옷ߦᗩᴥᕤᕦⵙⵔⵙⵔⵙᕤᕦᴥᗩߦ옷ⵔO8ᒍᒐᗱᗴᑐᑕ𖧷ᔓᔕⵙ.Scatter(x=ⵙᔓᔕᗱᗴ𖧷ᗩИNꖴᗝᴥOᑐᑕⵔꕤⵙⵔⵙⵔⵙꕤⵔᑐᑕOᴥᗝꖴИNᗩ𖧷ᗱᗴᔓᔕⵙ,y=ⵙᔓᔕᗱᗴ𖧷ᗩИNꖴᗝᴥOᑐᑕⵔ人ⵙⵔⵙⵔⵙ人ⵔᑐᑕOᴥᗝꖴИNᗩ𖧷ᗱᗴᔓᔕⵙ,mode='lines',name='Curve'))
|
||
ⵙᗱᗴᴥᑎᕤᕦꖴꗳⵙⵔⵙⵔⵙꗳꖴᕤᕦᑎᴥᗱᗴⵙ.update_layout(autosize=True,xaxis=dict(scaleanchor='y',scaleratio=1))
|
||
ⵙᗱᗴᴥᑎᕤᕦꖴꗳⵙⵔⵙⵔⵙꗳꖴᕤᕦᑎᴥᗱᗴⵙ.show() |