FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/Complex_Distribution_Visualization.java at main · sksalahuddin2828/Java · GitHub
sksalahuddin2828
/
Java
Public
Notifications
You must be signed in to change notification settings
Fork
59
Star
178
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
Complex_Distribution_Visualization.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (56 loc) · 2.55 KB
Breadcrumbs
Java
/
Complex_Distribution_Visualization.java
Copy path
File metadata and controls
66 lines (56 loc) · 2.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import
javafx
.
application
.
Application
;
import
javafx
.
scene
.
Scene
;
import
javafx
.
scene
.
chart
.
LineChart
;
import
javafx
.
scene
.
chart
.
NumberAxis
;
import
javafx
.
scene
.
chart
.
XYChart
;
import
javafx
.
stage
.
Stage
;
public
class
ComplexDistributionVisualization
extends
Application
{
@
Override
public
void
start
(
Stage
primaryStage
) {
// Define the data range for the X-axis
double
startX
= -
5.0
;
double
endX
=
30.0
;
int
numPoints
=
500
;
// Generate data points for visualization
double
[]
xValues
=
new
double
[
numPoints
];
double
[]
yValues
=
new
double
[
numPoints
];
double
step
= (
endX
-
startX
) / (
numPoints
-
1
);
for
(
int
i
=
0
;
i
<
numPoints
;
i
++) {
xValues
[
i
] =
startX
+
i
*
step
;
yValues
[
i
] =
complexDistribution
(
xValues
[
i
]);
}
// Create the line chart
NumberAxis
xAxis
=
new
NumberAxis
(
startX
,
endX
,
step
);
NumberAxis
yAxis
=
new
NumberAxis
();
LineChart
<
Number
,
Number
>
lineChart
=
new
LineChart
<>(
xAxis
,
yAxis
);
lineChart
.
setTitle
(
"Complex Distribution"
);
lineChart
.
setCreateSymbols
(
false
);
// Remove data points symbols
// Add the complex distribution data to the chart
XYChart
.
Series
<
Number
,
Number
>
series
=
new
XYChart
.
Series
<>();
for
(
int
i
=
0
;
i
<
numPoints
;
i
++) {
series
.
getData
().
add
(
new
XYChart
.
Data
<>(
xValues
[
i
],
yValues
[
i
]));
}
lineChart
.
getData
().
add
(
series
);
// Create and show the scene
Scene
scene
=
new
Scene
(
lineChart
,
800
,
600
);
primaryStage
.
setTitle
(
"Complex Distribution Visualization"
);
primaryStage
.
setScene
(
scene
);
primaryStage
.
show
();
}
private
double
complexDistribution
(
double
x
) {
// Define a mixture of three Gaussian distributions
double
mu1
=
5
,
sigma1
=
1
;
double
mu2
=
12
,
sigma2
=
2
;
double
mu3
=
20
,
sigma3
=
3
;
// Calculate the PDF of each Gaussian distribution
double
pdf1
=
Math
.
exp
(-
0.5
*
Math
.
pow
((
x
-
mu1
) /
sigma1
,
2
)) / (
sigma1
*
Math
.
sqrt
(
2
*
Math
.
PI
));
double
pdf2
=
Math
.
exp
(-
0.5
*
Math
.
pow
((
x
-
mu2
) /
sigma2
,
2
)) / (
sigma2
*
Math
.
sqrt
(
2
*
Math
.
PI
));
double
pdf3
=
Math
.
exp
(-
0.5
*
Math
.
pow
((
x
-
mu3
) /
sigma3
,
2
)) / (
sigma3
*
Math
.
sqrt
(
2
*
Math
.
PI
));
// Combine the three PDFs to create a complex distribution
// You can adjust the weights to change the contribution of each Gaussian
return
0.4
*
pdf1
+
0.3
*
pdf2
+
0.3
*
pdf3
;
}
public
static
void
main
(
String
[]
args
) {
launch
(
args
);
}
}
Back
|
FazBrowse Home
|
New Git URL